public final class LongBitSet extends Object
getBits()
)
long[], accessed with a long index. Use it only if you intend to store more
than 2.1B bits, otherwise you should use FixedBitSet
.Constructor and Description |
---|
LongBitSet(long numBits)
Creates a new LongBitSet.
|
LongBitSet(long[] storedBits,
long numBits)
Creates a new LongBitSet using the provided long[] array as backing store.
|
Modifier and Type | Method and Description |
---|---|
void |
and(LongBitSet other)
this = this AND other
|
void |
andNot(LongBitSet other)
this = this AND NOT other
|
static int |
bits2words(long numBits)
returns the number of 64 bit words it would take to hold numBits
|
long |
cardinality()
Returns number of set bits.
|
void |
clear(long index) |
void |
clear(long startIndex,
long endIndex)
Clears a range of bits.
|
LongBitSet |
clone() |
static LongBitSet |
ensureCapacity(LongBitSet bits,
long numBits)
If the given
LongBitSet is large enough to hold
numBits+1 , returns the given bits, otherwise returns a new
LongBitSet which can hold the requested number of bits. |
boolean |
equals(Object o)
returns true if both sets have the same bits set
|
void |
flip(long index)
Flip the bit at the provided index.
|
void |
flip(long startIndex,
long endIndex)
Flips a range of bits
|
boolean |
get(long index) |
boolean |
getAndClear(long index) |
boolean |
getAndSet(long index) |
long[] |
getBits()
Expert.
|
int |
hashCode() |
boolean |
intersects(LongBitSet other)
returns true if the sets have any elements in common
|
long |
length()
Returns the number of bits stored in this bitset.
|
long |
nextSetBit(long index)
Returns the index of the first set bit starting at the index specified.
|
void |
or(LongBitSet other)
this = this OR other
|
long |
prevSetBit(long index)
Returns the index of the last set bit before or on the index specified.
|
boolean |
scanIsEmpty()
Scans the backing store to check if all bits are clear.
|
void |
set(long index) |
void |
set(long startIndex,
long endIndex)
Sets a range of bits
|
void |
xor(LongBitSet other)
this = this XOR other
|
public LongBitSet(long numBits)
numBits
- the number of bits neededpublic LongBitSet(long[] storedBits, long numBits)
storedBits
- the array to use as backing storenumBits
- the number of bits actually neededpublic static LongBitSet ensureCapacity(LongBitSet bits, long numBits)
LongBitSet
is large enough to hold
numBits+1
, returns the given bits, otherwise returns a new
LongBitSet
which can hold the requested number of bits.
NOTE: the returned bitset reuses the underlying long[]
of
the given bits
if possible. Also, calling length()
on the
returned bits may return a value greater than numBits
.
public static int bits2words(long numBits)
public long length()
public long[] getBits()
public long cardinality()
public boolean get(long index)
public void set(long index)
public boolean getAndSet(long index)
public void clear(long index)
public boolean getAndClear(long index)
public long nextSetBit(long index)
public long prevSetBit(long index)
public void or(LongBitSet other)
public void xor(LongBitSet other)
public boolean intersects(LongBitSet other)
public void and(LongBitSet other)
public void andNot(LongBitSet other)
public boolean scanIsEmpty()
public void flip(long startIndex, long endIndex)
startIndex
- lower indexendIndex
- one-past the last bit to flippublic void flip(long index)
public void set(long startIndex, long endIndex)
startIndex
- lower indexendIndex
- one-past the last bit to setpublic void clear(long startIndex, long endIndex)
startIndex
- lower indexendIndex
- one-past the last bit to clearpublic LongBitSet clone()
public boolean equals(Object o)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.