| java.lang.Object java.util.BitSet
BitSet | public class BitSet implements Serializable,Cloneable(Code) | | The BitSet class implements a bit field. Each element in a BitSet can be
on(1) or off(0). A BitSet is created with a given size and grows when this
size is exceeded. Growth is always rounded to a 64 bit boundary.
|
Constructor Summary | |
public | BitSet() | public | BitSet(int nbits) Create a new BitSet with size equal to nbits. |
Method Summary | |
public void | and(BitSet bs) Performs the logical AND of this BitSet with another BitSet. | public void | andNot(BitSet bs) Clears all bits in the receiver which are also set in the parameter
BitSet. | public int | cardinality() Answers the number of bits that are true in this bitset. | public void | clear() Clears all the bits in this bitset. | public void | clear(int pos) Clears the bit at index pos. | public void | clear(int pos1, int pos2) Clears the bits starting from pos1 to pos2. | public Object | clone() | public boolean | equals(Object obj) Compares the argument to this BitSet and answer if they are equal. | public void | flip(int pos) Flips the bit at index pos. | public void | flip(int pos1, int pos2) Flips the bits starting from pos1 to pos2. | public boolean | get(int pos) Retrieve the bit at index pos. | public BitSet | get(int pos1, int pos2) Retrieves the bits starting from pos1 to pos2 and answers back a new
bitset made of these bits. | public int | hashCode() Computes the hash code for this BitSet. | public boolean | intersects(BitSet bs) Checks if these two bitsets have at least one bit set to true in the same
position. | public boolean | isEmpty() Answers true if all the bits in this bitset are set to false. | public int | length() Returns the number of bits up to and including the highest bit set. | public int | nextClearBit(int pos) | public int | nextSetBit(int pos) | public void | or(BitSet bs) Performs the logical OR of this BitSet with another BitSet. | public void | set(int pos) Sets the bit at index pos to 1. | public void | set(int pos, boolean val) Sets the bit at index pos to the value. | public void | set(int pos1, int pos2) Sets the bits starting from pos1 to pos2. | public void | set(int pos1, int pos2, boolean val) Sets the bits starting from pos1 to pos2 to the given boolean value. | public int | size() Answers the number of bits this bitset has. | public String | toString() Answers a string containing a concise, human-readable description of the
receiver. | public void | xor(BitSet bs) Performs the logical XOR of this BitSet with another BitSet. |
and | public void and(BitSet bs)(Code) | | Performs the logical AND of this BitSet with another BitSet.
Parameters: bs - BitSet to AND with See Also: BitSet.or See Also: BitSet.xor |
andNot | public void andNot(BitSet bs)(Code) | | Clears all bits in the receiver which are also set in the parameter
BitSet.
Parameters: bs - BitSet to ANDNOT with |
cardinality | public int cardinality()(Code) | | Answers the number of bits that are true in this bitset.
the number of true bits in the set |
clear | public void clear(int pos1, int pos2)(Code) | | Clears the bits starting from pos1 to pos2. Grows the BitSet if pos2 >
size.
Parameters: pos1 - beginning position Parameters: pos2 - ending position throws: IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smallerthan pos1 See Also: BitSet.clear(int) |
clone | public Object clone()(Code) | | Create a copy of this BitSet
A copy of this BitSet. |
equals | public boolean equals(Object obj)(Code) | | Compares the argument to this BitSet and answer if they are equal. The
object must be an instance of BitSet with the same bits set.
Parameters: obj - the BitSet object to compare A boolean indicating whether or not this BitSet and obj are equal See Also: BitSet.hashCode |
flip | public void flip(int pos1, int pos2)(Code) | | Flips the bits starting from pos1 to pos2. Grows the BitSet if pos2 >
size.
Parameters: pos1 - beginning position Parameters: pos2 - ending position throws: IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smallerthan pos1 See Also: BitSet.flip(int) |
get | public BitSet get(int pos1, int pos2)(Code) | | Retrieves the bits starting from pos1 to pos2 and answers back a new
bitset made of these bits. Grows the BitSet if pos2 > size.
Parameters: pos1 - beginning position Parameters: pos2 - ending position new bitset throws: IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smallerthan pos1 See Also: BitSet.get(int) |
intersects | public boolean intersects(BitSet bs)(Code) | | Checks if these two bitsets have at least one bit set to true in the same
position.
Parameters: bs - BitSet used to calculate intersect true if bs intersects with this BitSet,false otherwise |
isEmpty | public boolean isEmpty()(Code) | | Answers true if all the bits in this bitset are set to false.
true if the BitSet is empty, false otherwise |
length | public int length()(Code) | | Returns the number of bits up to and including the highest bit set.
the length of the BitSet |
nextClearBit | public int nextClearBit(int pos)(Code) | | Answers the position of the first bit that is false on or after pos
Parameters: pos - the starting position (inclusive) the position of the next bit set to false, even if it is furtherthan this bitset's size. |
nextSetBit | public int nextSetBit(int pos)(Code) | | Answers the position of the first bit that is true on or after pos
Parameters: pos - the starting position (inclusive) -1 if there is no bits that are set to true on or after pos. |
or | public void or(BitSet bs)(Code) | | Performs the logical OR of this BitSet with another BitSet.
Parameters: bs - BitSet to OR with See Also: BitSet.xor See Also: BitSet.and |
set | public void set(int pos, boolean val)(Code) | | Sets the bit at index pos to the value. Grows the BitSet if pos > size.
Parameters: pos - the index of the bit to set Parameters: val - value to set the bit throws: IndexOutOfBoundsException - when pos < 0 See Also: BitSet.set(int) |
set | public void set(int pos1, int pos2)(Code) | | Sets the bits starting from pos1 to pos2. Grows the BitSet if pos2 >
size.
Parameters: pos1 - beginning position Parameters: pos2 - ending position throws: IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smallerthan pos1 See Also: BitSet.set(int) |
set | public void set(int pos1, int pos2, boolean val)(Code) | | Sets the bits starting from pos1 to pos2 to the given boolean value.
Grows the BitSet if pos2 > size.
Parameters: pos1 - beginning position Parameters: pos2 - ending position Parameters: val - value to set these bits throws: IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smallerthan pos1 See Also: BitSet.set(int,int) |
size | public int size()(Code) | | Answers the number of bits this bitset has.
The number of bits contained in this BitSet. See Also: BitSet.length |
toString | public String toString()(Code) | | Answers a string containing a concise, human-readable description of the
receiver.
A comma delimited list of the indices of all bits that are set. |
xor | public void xor(BitSet bs)(Code) | | Performs the logical XOR of this BitSet with another BitSet.
Parameters: bs - BitSet to XOR with See Also: BitSet.or See Also: BitSet.and |
|
|