|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.javaewah.datastructure.BitSet
public class BitSet
This is an optimized version of Java's BitSet. In many cases, it can be used as a drop-in replacement. It differs from the basic Java BitSet class in the following ways:
for(int bs: mybitset)
.
Constructor Summary | |
---|---|
BitSet(int sizeinbits)
Construct a bitset with the specified number of bits (initially all false). |
Method Summary | |
---|---|
void |
and(BitSet bs)
Compute bitwise AND. |
int |
andcardinality(BitSet bs)
Compute cardinality of bitwise AND. |
void |
andNot(BitSet bs)
Compute bitwise AND NOT. |
int |
andNotcardinality(BitSet bs)
Compute cardinality of bitwise AND NOT. |
int |
cardinality()
Compute the number of bits set to 1 |
void |
clear()
Reset all bits to false. |
BitSet |
clone()
|
boolean |
empty()
Check whether a bitset contains a set bit. |
boolean |
equals(Object o)
|
boolean |
get(int i)
|
int |
hashCode()
|
boolean |
intersects(BitSet bs)
Checks whether two bitsets intersect. |
IntIterator |
intIterator()
Iterate over the set bits |
Iterator<Integer> |
iterator()
|
int |
nextSetBit(int i)
Usage: for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { operate on index i here } |
int |
nextUnsetBit(int i)
Usage: for(int i=bs.nextUnsetBit(0); i>=0; i=bs.nextUnsetBit(i+1)) { operate on index i here } |
void |
or(BitSet bs)
Compute bitwise OR. |
int |
orcardinality(BitSet bs)
Compute cardinality of bitwise OR. |
void |
readExternal(ObjectInput in)
|
void |
resize(int sizeinbits)
Resize the bitset |
void |
set(int i)
Set to true |
void |
set(int i,
boolean b)
|
int |
size()
Query the size |
void |
trim()
Recovers wasted memory |
void |
unset(int i)
Set to false |
IntIterator |
unsetIntIterator()
Iterate over the unset bits |
void |
writeExternal(ObjectOutput out)
|
void |
xor(BitSet bs)
Compute bitwise XOR. |
int |
xorcardinality(BitSet bs)
Compute cardinality of bitwise XOR. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitSet(int sizeinbits)
sizeinbits
- the size in bitsMethod Detail |
---|
public void and(BitSet bs)
bs
- other bitsetpublic int andcardinality(BitSet bs)
bs
- other bitset
public void andNot(BitSet bs)
bs
- other bitsetpublic int andNotcardinality(BitSet bs)
bs
- other bitset
public int cardinality()
public void clear()
public BitSet clone()
clone
in class Object
public boolean equals(Object o)
equals
in class Object
public boolean empty()
public boolean get(int i)
i
- index
public int hashCode()
hashCode
in class Object
public IntIterator intIterator()
public Iterator<Integer> iterator()
iterator
in interface Iterable<Integer>
public boolean intersects(BitSet bs)
bs
- other bitset
public int nextSetBit(int i)
i
- current set bit
public int nextUnsetBit(int i)
i
- current unset bit
public void or(BitSet bs)
bs
- other bitsetpublic int orcardinality(BitSet bs)
bs
- other bitset
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void resize(int sizeinbits)
sizeinbits
- new number of bitspublic void set(int i)
i
- index of the bitpublic void set(int i, boolean b)
i
- indexb
- value of the bitpublic int size()
public void trim()
public void unset(int i)
i
- index of the bitpublic IntIterator unsetIntIterator()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void xor(BitSet bs)
bs
- other bitsetpublic int xorcardinality(BitSet bs)
bs
- other bitset
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |