public class ImmutableBitSet extends java.lang.Object implements java.lang.Cloneable, java.lang.Iterable<java.lang.Integer>, WordArray
final FileOutputStream fos = new FileOutputStream(tmpfile); BitSet Bitmap = BitSet.bitmapOf(0, 2, 55, 64, 512); Bitmap.serialize(new DataOutputStream(fos)); RandomAccessFile memoryMappedFile = new RandomAccessFile(tmpfile, "r"); ByteBuffer bb = memoryMappedFile.getChannel().map( FileChannel.MapMode.READ_ONLY, 0, totalcount); ImmutableBitSet mapped = new ImmutableBitSet(bb.asLongBuffer());
Modifier and Type | Field and Description |
---|---|
private java.nio.LongBuffer |
data |
Constructor and Description |
---|
ImmutableBitSet(java.nio.LongBuffer bs)
Construct a ImmutableBitSet from the content of the LongBuffer
which should have been initialized with BitSet.serialize (from the BitSet in this
same package).
|
Modifier and Type | Method and Description |
---|---|
BitSet |
asBitSet()
Get a copy of this ImmutableBitSet as a mutable BitSet.
|
int |
cardinality()
Compute the number of bits set to 1
|
ImmutableBitSet |
clone() |
boolean |
empty()
Check whether a bitset contains a set bit.
|
boolean |
equals(java.lang.Object o) |
boolean |
get(int i) |
int |
getNumberOfWords()
Get the total number of words contained in this data structure.
|
long |
getWord(int index)
Get the word at the given index
|
int |
hashCode() |
boolean |
intersects(BitSet bs)
Checks whether two bitsets intersect.
|
IntIterator |
intIterator()
Iterate over the set bits
|
java.util.Iterator<java.lang.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 }
|
int |
size()
Query the size
|
java.lang.String |
toString() |
IntIterator |
unsetIntIterator()
Iterate over the unset bits
|
public ImmutableBitSet(java.nio.LongBuffer bs)
bs
- the data sourcepublic BitSet asBitSet()
public int cardinality()
public ImmutableBitSet clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean empty()
public boolean get(int i)
i
- indexpublic int hashCode()
hashCode
in class java.lang.Object
public IntIterator intIterator()
public java.util.Iterator<java.lang.Integer> iterator()
iterator
in interface java.lang.Iterable<java.lang.Integer>
public boolean intersects(BitSet bs)
bs
- other bitsetpublic int nextSetBit(int i)
i
- current set bitpublic int nextUnsetBit(int i)
i
- current unset bitpublic int size()
public IntIterator unsetIntIterator()
public int getNumberOfWords()
WordArray
getNumberOfWords
in interface WordArray
public long getWord(int index)
WordArray
public java.lang.String toString()
toString
in class java.lang.Object