|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.BitSet
public class BitSet
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 | |
|---|---|
BitSet()
Create a new BitSet with size equal to 64 bits |
|
BitSet(int nbits)
Create a new BitSet with size equal to nbits. |
|
| Method Summary | |
|---|---|
void |
and(BitSet bs)
Performs the logical AND of this BitSet with another BitSet. |
void |
andNot(BitSet bs)
Clears all bits in the receiver which are also set in the parameter BitSet. |
int |
cardinality()
Returns the number of bits that are true in this bitset. |
void |
clear()
Clears all the bits in this bitset. |
void |
clear(int pos)
Clears the bit at index pos. |
void |
clear(int pos1,
int pos2)
Clears the bits starting from pos1 to pos2. |
Object |
clone()
Create a copy of this BitSet |
boolean |
equals(Object obj)
Compares the argument to this BitSet and answer if they are equal. |
void |
flip(int pos)
Flips the bit at index pos. |
void |
flip(int pos1,
int pos2)
Flips the bits starting from pos1 to pos2. |
boolean |
get(int pos)
Retrieve the bit at index pos. |
BitSet |
get(int pos1,
int pos2)
Retrieves the bits starting from pos1 to pos2 and returns back a new bitset made of these bits. |
int |
hashCode()
Computes the hash code for this BitSet. |
boolean |
intersects(BitSet bs)
Checks if these two bitsets have at least one bit set to true in the same position. |
boolean |
isEmpty()
Returns true if all the bits in this bitset are set to false. |
int |
length()
Returns the number of bits up to and including the highest bit set. |
int |
nextClearBit(int pos)
Returns the position of the first bit that is false on or after pos |
int |
nextSetBit(int pos)
Returns the position of the first bit that is true on or after pos |
void |
or(BitSet bs)
Performs the logical OR of this BitSet with another BitSet. |
void |
set(int pos)
Sets the bit at index pos to 1. |
void |
set(int pos,
boolean val)
Sets the bit at index pos to the value. |
void |
set(int pos1,
int pos2)
Sets the bits starting from pos1 to pos2. |
void |
set(int pos1,
int pos2,
boolean val)
Sets the bits starting from pos1 to pos2 to the given boolean value. |
int |
size()
Returns the number of bits this bitset has. |
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
void |
xor(BitSet bs)
Performs the logical XOR of this BitSet with another BitSet. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BitSet()
clear(int),
set(int),
clear(),
clear(int, int),
set(int, boolean),
set(int, int),
set(int, int, boolean)public BitSet(int nbits)
nbits - the size of the bit set
NegativeArraySizeException - if nbits < 0.clear(int),
set(int),
clear(),
clear(int, int),
set(int, boolean),
set(int, int),
set(int, int, boolean)| Method Detail |
|---|
public Object clone()
clone in class Objectpublic boolean equals(Object obj)
equals in class Objectobj - the BitSet object to compare
hashCode()public int hashCode()
hashCode in class Objectint representing the hash code for this bit
set.equals(java.lang.Object),
Hashtablepublic boolean get(int pos)
pos - the index of the bit to be retrieved
true if the bit at pos is set,
false otherwise
IndexOutOfBoundsException - when pos < 0clear(int),
set(int),
clear(),
clear(int, int),
set(int, boolean),
set(int, int),
set(int, int, boolean)
public BitSet get(int pos1,
int pos2)
pos1 - beginning positionpos2 - ending position
IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smaller
than pos1get(int)public void set(int pos)
pos - the index of the bit to set
IndexOutOfBoundsException - when pos < 0clear(int),
clear(),
clear(int, int)
public void set(int pos,
boolean val)
pos - the index of the bit to setval - value to set the bit
IndexOutOfBoundsException - when pos < 0set(int)
public void set(int pos1,
int pos2)
pos1 - beginning positionpos2 - ending position
IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smaller
than pos1set(int)
public void set(int pos1,
int pos2,
boolean val)
pos1 - beginning positionpos2 - ending positionval - value to set these bits
IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smaller
than pos1set(int,int)public void clear()
clear(int),
clear(int, int)public void clear(int pos)
pos - the index of the bit to clear
IndexOutOfBoundsException - when pos < 0clear(int, int)
public void clear(int pos1,
int pos2)
pos1 - beginning positionpos2 - ending position
IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smaller
than pos1clear(int)public void flip(int pos)
pos - the index of the bit to flip
IndexOutOfBoundsException - when pos < 0flip(int, int)
public void flip(int pos1,
int pos2)
pos1 - beginning positionpos2 - ending position
IndexOutOfBoundsException - when pos1 or pos2 is negative, or when pos2 is not smaller
than pos1flip(int)public boolean intersects(BitSet bs)
bs - BitSet used to calculate intersect
true if bs intersects with this BitSet,
false otherwisepublic void and(BitSet bs)
bs - BitSet to AND withor(java.util.BitSet),
xor(java.util.BitSet)public void andNot(BitSet bs)
bs - BitSet to ANDNOT withpublic void or(BitSet bs)
bs - BitSet to OR withxor(java.util.BitSet),
and(java.util.BitSet)public void xor(BitSet bs)
bs - BitSet to XOR withor(java.util.BitSet),
and(java.util.BitSet)public int size()
length()public int length()
public String toString()
toString in class Objectpublic int nextSetBit(int pos)
pos - the starting position (inclusive)
public int nextClearBit(int pos)
pos - the starting position (inclusive)
public boolean isEmpty()
true if the BitSet is empty, false
otherwisepublic int cardinality()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||