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) |
LongBitSet(long[] storedBits,
long numBits) |
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 , 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 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.
|
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)
public LongBitSet(long[] storedBits, long numBits)
public static LongBitSet ensureCapacity(LongBitSet bits, long numBits)
LongBitSet
is large enough to hold
numBits
, 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 void flip(long startIndex, long endIndex)
startIndex
- lower indexendIndex
- one-past the last bit to flippublic 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-2014 Apache Software Foundation. All Rights Reserved.