KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > util > BitSet

java.util
Class BitSet

java.lang.Object
  extended by java.util.BitSet
All Implemented Interfaces:
Serializable, Cloneable
See Also:
Top Examples, Source Code

public void and(BitSet set)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void andNot(BitSet set)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public BitSet()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public BitSet(int nbits)
See Also:
NegativeArraySizeException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int cardinality()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1437]Set the 0th and 1000th bits, and display its attributes
By cgselvan2002 { at } yahoo { dot } com (c { dot } gokulaselvan) on 2005/10/05 05:04:35  Rate
import java.util.BitSet; 
 public class BitSet1  {  
         public static void main ( String args [  ]  )   {  
      
             // create a BitSet 
      
             BitSet bitset = new BitSet (  ) ; 
      
             // set the 0th and 1000th bits 
      
             bitset.set ( 0 ) ; 
             bitset.set ( 5000 ) ; 
      
             // display the size, length,  
             // and cardinality 
      
             System.out.println (  
                 "size = " + bitset.size (  )  ) ; 
             System.out.println (  
                 "length = " + bitset.length (  )  ) ; 
             System.out.println ( "cardinality = " + 
                 bitset.cardinality (  )  ) ; 
      
          }  
      } 


public void clear()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1438]Create and clearn bitset
By cgselvan2002 { at } yahoo { dot } com(c { dot } gokulaselvan) on 2005/05/21 02:45:56  Rate
import java.util.BitSet; 
 public class BitSet1  {  
         public static void main ( String args [  ]  )   {  
      
             // create a BitSet 
      
             BitSet bitset = new BitSet (  ) ; 
      
             // set the 0th and 1000th bits 
      
             bitset.set ( 0 ) ; 
             bitset.set ( 5000 ) ; 
      
             // display the size, length,  
             // and cardinality 
      
             System.out.println (  
                 "size = " + bitset.size (  )  ) ; 
             System.out.println (  
                 "length = " + bitset.length (  )  ) ; 
             System.out.println ( "cardinality = " + 
                 bitset.cardinality (  )  ) ; 
           bitset.clear (  ) ; 
           System.out.println ( bitset.size (  )  ) ;             
           System.out.println ( bitset.length (  )  ) ;             
           System.out.println ( bitset.cardinality (  )  ) ;   
          
          }  
      } 


public void clear(int bitIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void clear(int fromIndex,
                  int toIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Object clone()
See Also:
size()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1439]Make a copy of bitset and XOR
By cgselvan2002 { at } yahoo { dot } com(c { dot } gokulaselvan) on 2005/05/21 02:53:55  Rate
import java.util.BitSet; 
      
     public class BitSet3  {  
         public static void main ( String args [  ]  )   {  
      
             // create two sets of bits 
      
             BitSet bitset1 = new BitSet (  ) ; 
             bitset1.set ( 1 ) ; 
             bitset1.set ( 3 ) ; 
              
      
             BitSet bitset2 = new BitSet (  ) ; 
             bitset2.set ( 1 ) ; 
             bitset2.set ( 3 ) ; 
             bitset2.set ( 11 ) ; 
             bitset2.set ( 12 ) ; 
      
             // make a copy of the first one and XOR  
             // with the second 
      
             BitSet result =  ( BitSet ) bitset1.clone (  ) ; 
             result.or ( bitset2 ) ; 
      
             System.out.println ( bitset1 + " XOR " +  
                 bitset2 + " = " + result ) ; 
          }  
      } 


public boolean equals(Object obj)
See Also:
size()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void flip(int bitIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void flip(int fromIndex,
                 int toIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean get(int bitIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public BitSet get(int fromIndex,
                  int toIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1440]Get bits from 0 (inclusive) to 5 (exclusive)
By cgselvan2002 { at } yahoo { dot } com(c { dot } gokulaselvan) on 2005/05/21 02:57:09  Rate
//cgselvan2002@yahoo.com 
 import java.util.BitSet; 
      
     public class BitSet4  {  
         public static void main ( String args [  ]  )   {  
             BitSet bitset1 = new BitSet (  ) ; 
      
             // set bits from 0  ( inclusive )   
             // to 50  ( exclusive )  
      
             bitset1.set ( 0, 50 ) ; 
      
             // get bits from 0  ( inclusive )   
             // to 5  ( exclusive )  
      
             BitSet bitset2 = bitset1.get ( 0, 5 ) ; 
      
             System.out.println ( bitset2 ) ; 
          }  
      } 


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean intersects(BitSet set)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isEmpty()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int length()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int nextClearBit(int fromIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int nextSetBit(int fromIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void or(BitSet set)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void set(int bitIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void set(int bitIndex,
                boolean value)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void set(int fromIndex,
                int toIndex)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void set(int fromIndex,
                int toIndex,
                boolean value)
See Also:
IndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int size()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void xor(BitSet set)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags