public class Roaring64NavigableMap extends Object implements Externalizable, LongBitmapDataProvider
Constructor and Description |
---|
Roaring64NavigableMap()
By default, we consider longs are unsigned longs: normal longs: 0 is the lowest possible long.
|
Roaring64NavigableMap(BitmapDataProviderSupplier supplier)
By default, longs are managed as unsigned longs and cardinalities are cached.
|
Roaring64NavigableMap(boolean signedLongs)
By default, use RoaringBitmap as underlyings
BitmapDataProvider |
Roaring64NavigableMap(boolean signedLongs,
BitmapDataProviderSupplier supplier)
By default, we activating cardinalities caching.
|
Roaring64NavigableMap(boolean signedLongs,
boolean cacheCardinalities)
By default, use RoaringBitmap as underlyings
BitmapDataProvider |
Roaring64NavigableMap(boolean signedLongs,
boolean cacheCardinalities,
BitmapDataProviderSupplier supplier) |
Modifier and Type | Method and Description |
---|---|
void |
add(long... dat)
Set all the specified values to true.
|
void |
add(long rangeStart,
long rangeEnd)
Add to the current bitmap all longs in [rangeStart,rangeEnd).
|
void |
addInt(int x)
Add the integer value to the container (set the value to "true"), whether it already appears or
not.
|
void |
addLong(long x)
Add the value to the container (set the value to "true"), whether it already appears or not.
|
void |
and(Roaring64NavigableMap x2)
In-place bitwise AND (intersection) operation.
|
void |
andNot(Roaring64NavigableMap x2)
In-place bitwise ANDNOT (difference) operation.
|
static Roaring64NavigableMap |
bitmapOf(long... dat)
Generate a bitmap with the specified values set to true.
|
void |
clear()
reset to an empty bitmap; result occupies as much space a newly created bitmap.
|
boolean |
contains(long x)
Checks whether the value in included, which is equivalent to checking if the corresponding bit
is set (get in BitSet class).
|
void |
deserialize(DataInput in)
Deserialize (retrieve) this bitmap.
|
protected int |
ensureCumulatives(int high) |
boolean |
equals(Object obj) |
void |
flip(long x)
Add the value if it is not already present, otherwise remove it.
|
void |
forEach(LongConsumer lc)
Visit all values in the bitmap and pass them to the consumer.
|
int |
getIntCardinality() |
long |
getLongCardinality()
Returns the number of distinct integers added to the bitmap (e.g., number of bits set).
|
LongIterator |
getLongIterator()
For better performance, consider the Use the
forEach method. |
long |
getLongSizeInBytes()
Estimate of the memory usage of this data structure.
|
LongIterator |
getReverseLongIterator() |
int |
getSizeInBytes()
Estimate of the memory usage of this data structure.
|
int |
hashCode() |
boolean |
isEmpty()
Checks whether the bitmap is empty.
|
Iterator<Long> |
iterator()
For better performance, consider the Use the
forEach method. |
ImmutableLongBitmapDataProvider |
limit(long x)
Create a new bitmap of the same class, containing at most maxcardinality integers.
|
void |
or(Roaring64NavigableMap x2)
In-place bitwise OR (union) operation.
|
long |
rankLong(long id)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be
GetCardinality()).
|
void |
readExternal(ObjectInput in) |
void |
removeLong(long x)
If present remove the specified integers (effectively, sets its bit value to false)
|
boolean |
runOptimize()
Use a run-length encoding where it is estimated as more space efficient
|
long |
select(long j)
Return the jth value stored in this bitmap.
|
void |
serialize(DataOutput out)
Serialize this bitmap.
|
long |
serializedSizeInBytes()
Report the number of bytes required to serialize this bitmap.
|
long[] |
toArray()
Return the set values as an array, if the cardinality is smaller than 2147483648.
|
protected LongIterator |
toIterator(Iterator<Map.Entry<Integer,BitmapDataProvider>> it,
boolean reversed) |
String |
toString()
A string describing the bitmap.
|
void |
trim()
Recover allocated but unused memory.
|
void |
writeExternal(ObjectOutput out)
Roaring64NavigableMap are serializable. |
void |
xor(Roaring64NavigableMap x2)
In-place bitwise XOR (symmetric difference) operation.
|
public Roaring64NavigableMap()
public Roaring64NavigableMap(boolean signedLongs)
BitmapDataProvider
signedLongs
- true if longs has to be ordered as plain java longs. False to handle them as
unsigned 64bits long (as RoaringBitmap with unsigned integers)public Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities)
BitmapDataProvider
signedLongs
- true if longs has to be ordered as plain java longs. False to handle them as
unsigned 64bits long (as RoaringBitmap with unsigned integers)cacheCardinalities
- true if cardinalities have to be cached. It will prevent many
iteration along the NavigableMappublic Roaring64NavigableMap(BitmapDataProviderSupplier supplier)
supplier
- provide the logic to instantiate new BitmapDataProvider
, typically
instantiated once per high.public Roaring64NavigableMap(boolean signedLongs, BitmapDataProviderSupplier supplier)
signedLongs
- true if longs has to be ordered as plain java longs. False to handle them as
unsigned 64bits long (as RoaringBitmap with unsigned integers)supplier
- provide the logic to instantiate new BitmapDataProvider
, typically
instantiated once per high.public Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities, BitmapDataProviderSupplier supplier)
signedLongs
- true if longs has to be ordered as plain java longs. False to handle them as
unsigned 64bits long (as RoaringBitmap with unsigned integers)cacheCardinalities
- true if cardinalities have to be cached. It will prevent many
iteration along the NavigableMapsupplier
- provide the logic to instantiate new BitmapDataProvider
, typically
instantiated once per high.public void addLong(long x)
Long.compareUnsigned(long, long)
. We order the numbers
like 0, 1, ..., 9223372036854775807, -9223372036854775808, -9223372036854775807,..., -1.addLong
in interface LongBitmapDataProvider
x
- long valuepublic void addInt(int x)
Integer.compareUnsigned(int, int)
. We order the numbers
like 0, 1, ..., 2147483647, -2147483648, -2147483647,..., -1.x
- integer valuepublic long getLongCardinality()
getLongCardinality
in interface ImmutableLongBitmapDataProvider
public int getIntCardinality() throws UnsupportedOperationException
UnsupportedOperationException
- if the cardinality does not fit in an intpublic long select(long j) throws IllegalArgumentException
select
in interface ImmutableLongBitmapDataProvider
j
- index of the valueIllegalArgumentException
- if j is out of the bounds of the bitmap cardinalitypublic Iterator<Long> iterator()
forEach
method.public void forEach(LongConsumer lc)
ImmutableLongBitmapDataProvider
bitmap.forEach(new LongConsumer() {
{@literal @}Override
public void accept(long value) {
// do something here
}});
}
forEach
in interface ImmutableLongBitmapDataProvider
lc
- the consumerpublic long rankLong(long id)
ImmutableLongBitmapDataProvider
rankLong
in interface ImmutableLongBitmapDataProvider
id
- upper limitprotected int ensureCumulatives(int high)
high
- for which high bucket should we compute the cardinalitypublic void or(Roaring64NavigableMap x2)
x2
- other bitmappublic void xor(Roaring64NavigableMap x2)
x2
- other bitmappublic void and(Roaring64NavigableMap x2)
x2
- other bitmappublic void andNot(Roaring64NavigableMap x2)
x2
- other bitmappublic void writeExternal(ObjectOutput out) throws IOException
Roaring64NavigableMap
are serializable. However, contrary to RoaringBitmap, the
serialization format is not well-defined: for now, it is strongly coupled with Java standard
serialization. Just like the serialization may be incompatible between various Java versions,
Roaring64NavigableMap
are subject to incompatibilities. Moreover, even on a given Java
versions, the serialization format may change from one RoaringBitmap version to anotherwriteExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public String toString()
public LongIterator getLongIterator()
forEach
method.getLongIterator
in interface ImmutableLongBitmapDataProvider
protected LongIterator toIterator(Iterator<Map.Entry<Integer,BitmapDataProvider>> it, boolean reversed)
public boolean contains(long x)
ImmutableLongBitmapDataProvider
contains
in interface ImmutableLongBitmapDataProvider
x
- long valuepublic int getSizeInBytes()
ImmutableLongBitmapDataProvider
getSizeInBytes
in interface ImmutableLongBitmapDataProvider
public long getLongSizeInBytes()
ImmutableLongBitmapDataProvider
getLongSizeInBytes
in interface ImmutableLongBitmapDataProvider
public boolean isEmpty()
ImmutableLongBitmapDataProvider
isEmpty
in interface ImmutableLongBitmapDataProvider
public ImmutableLongBitmapDataProvider limit(long x)
ImmutableLongBitmapDataProvider
limit
in interface ImmutableLongBitmapDataProvider
x
- maximal cardinalitypublic boolean runOptimize()
public void serialize(DataOutput out) throws IOException
runOptimize()
before serialization to improve compression.
The current bitmap is not modified.serialize
in interface ImmutableLongBitmapDataProvider
out
- the DataOutput streamIOException
- Signals that an I/O exception has occurred.public void deserialize(DataInput in) throws IOException
in
- the DataInput streamIOException
- Signals that an I/O exception has occurred.public long serializedSizeInBytes()
ImmutableLongBitmapDataProvider
serializedSizeInBytes
in interface ImmutableLongBitmapDataProvider
public void clear()
public long[] toArray()
toArray
in interface ImmutableLongBitmapDataProvider
public static Roaring64NavigableMap bitmapOf(long... dat)
dat
- set valuespublic void add(long... dat)
dat
- set valuespublic void add(long rangeStart, long rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic LongIterator getReverseLongIterator()
getReverseLongIterator
in interface ImmutableLongBitmapDataProvider
public void removeLong(long x)
LongBitmapDataProvider
removeLong
in interface LongBitmapDataProvider
x
- long value representing the index in a bitmappublic void trim()
LongBitmapDataProvider
trim
in interface LongBitmapDataProvider
public void flip(long x)
x
- long valueCopyright © 2018. All rights reserved.