Package org.roaringbitmap.buffer
Class MappeableBitmapContainer
- java.lang.Object
-
- org.roaringbitmap.buffer.MappeableContainer
-
- org.roaringbitmap.buffer.MappeableBitmapContainer
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Iterable<Short>
,WordStorage<MappeableContainer>
public final class MappeableBitmapContainer extends MappeableContainer implements Cloneable
Simple bitset-like container. Unlike org.roaringbitmap.BitmapContainer, this class uses a LongBuffer to store data.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
MAX_CAPACITY
static boolean
USE_BRANCHLESS
optimization flag: whether the cardinality of the bitmaps is maintained through branchless operation-
Fields inherited from class org.roaringbitmap.buffer.MappeableContainer
ContainerNames
-
-
Constructor Summary
Constructors Constructor Description MappeableBitmapContainer()
Create a bitmap container with all bits set to falseMappeableBitmapContainer(int firstOfRun, int lastOfRun)
Create a bitmap container with a run of ones from firstOfRun to lastOfRun, inclusive caller must ensure that the range isn't so small that an ArrayContainer should have been created insteadMappeableBitmapContainer(LongBuffer array, int initCardinality)
Construct a new BitmapContainer backed by the provided LongBuffer.MappeableBitmapContainer(BitmapContainer bc)
Creates a new bitmap container from a non-mappeable one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MappeableContainer
add(int begin, int end)
Return a new container with all shorts in [begin,end) added using an unsigned interpretation.MappeableContainer
add(short i)
Add a short to the container.MappeableArrayContainer
and(MappeableArrayContainer value2)
Computes the bitwise AND of this container with another (intersection).MappeableContainer
and(MappeableBitmapContainer value2)
Computes the bitwise AND of this container with another (intersection).MappeableContainer
and(MappeableRunContainer value2)
Computes the bitwise AND of this container with another (intersection).int
andCardinality(MappeableArrayContainer value2)
int
andCardinality(MappeableBitmapContainer value2)
int
andCardinality(MappeableRunContainer x)
MappeableContainer
andNot(MappeableArrayContainer value2)
Computes the bitwise ANDNOT of this container with another (difference).MappeableContainer
andNot(MappeableBitmapContainer value2)
Computes the bitwise ANDNOT of this container with another (difference).MappeableContainer
andNot(MappeableRunContainer value2)
Computes the bitwise ANDNOT of this container with another (difference).protected long
bitValue(short i)
protected int
cardinalityInRange(int start, int end)
void
clear()
Empties the containerMappeableBitmapContainer
clone()
protected void
computeCardinality()
Recomputes the cardinality of the bitmap.boolean
contains(int minimum, int supremum)
Checks whether the container contains the entire rangeboolean
contains(short i)
Checks whether the contain contains the provided valuestatic boolean
contains(ByteBuffer buf, int position, short i)
Checks whether the container contains the value i.protected boolean
contains(MappeableArrayContainer arrayContainer)
protected boolean
contains(MappeableBitmapContainer bitmapContainer)
protected boolean
contains(MappeableRunContainer runContainer)
boolean
equals(Object o)
protected void
fillArray(short[] array)
Fill the array with set bitsvoid
fillLeastSignificant16bits(int[] x, int i, int mask)
Fill the least significant 16 bits of the integer array, starting at index index, with the short values from this container.int
first()
Get the first integer held in the containerMappeableContainer
flip(short i)
Add a short to the container if it is not present, otherwise remove it.void
forEach(short msb, IntConsumer ic)
Iterate through the values of this container and pass them along to the IntConsumer, using msb as the 16 most significant bits.protected int
getArraySizeInBytes()
Size of the underlying arrayContainerBatchIterator
getBatchIterator()
Gets an iterator to visit the contents of the container in batchesint
getCardinality()
Computes the distinct number of short values in the container.ShortIterator
getReverseShortIterator()
Iterator to visit the short values in the container in descending order.PeekableShortIterator
getShortIterator()
Iterator to visit the short values in the container in ascending order.int
getSizeInBytes()
Computes an estimate of the memory usage of this container.int
hashCode()
MappeableContainer
iadd(int begin, int end)
Add all shorts in [begin,end) using an unsigned interpretation.MappeableContainer
iand(MappeableArrayContainer b2)
Computes the in-place bitwise AND of this container with another (intersection).MappeableContainer
iand(MappeableBitmapContainer b2)
Computes the in-place bitwise AND of this container with another (intersection).MappeableContainer
iand(MappeableRunContainer x)
Computes the in-place bitwise AND of this container with another (intersection).MappeableContainer
iandNot(MappeableArrayContainer b2)
Computes the in-place bitwise ANDNOT of this container with another (difference).MappeableContainer
iandNot(MappeableBitmapContainer b2)
Computes the in-place bitwise ANDNOT of this container with another (difference).MappeableContainer
iandNot(MappeableRunContainer x)
Computes the in-place bitwise ANDNOT of this container with another (difference).protected MappeableContainer
ilazyor(MappeableArrayContainer value2)
protected MappeableContainer
ilazyor(MappeableBitmapContainer x)
protected MappeableContainer
ilazyor(MappeableRunContainer x)
MappeableContainer
inot(int firstOfRange, int lastOfRange)
Computes the in-place bitwise NOT of this container (complement).boolean
intersects(int minimum, int supremum)
Checks if the container intersects with a rangeboolean
intersects(MappeableArrayContainer value2)
Returns true if the current container intersects the other container.boolean
intersects(MappeableBitmapContainer value2)
Returns true if the current container intersects the other container.boolean
intersects(MappeableRunContainer x)
Returns true if the current container intersects the other container.MappeableBitmapContainer
ior(MappeableArrayContainer value2)
Computes the in-place bitwise OR of this container with another (union).MappeableContainer
ior(MappeableBitmapContainer b2)
Computes the in-place bitwise OR of this container with another (union).MappeableContainer
ior(MappeableRunContainer x)
Computes the in-place bitwise OR of this container with another (union).MappeableContainer
iremove(int begin, int end)
Remove shorts in [begin,end) using an unsigned interpretation.protected boolean
isArrayBacked()
boolean
isEmpty()
Checks whether the container is empty or not.protected boolean
isFull()
Iterator<Short>
iterator()
MappeableContainer
ixor(MappeableArrayContainer value2)
Computes the in-place bitwise XOR of this container with another (symmetric difference).MappeableContainer
ixor(MappeableBitmapContainer b2)
Computes the in-place bitwise XOR of this container with another (symmetric difference).MappeableContainer
ixor(MappeableRunContainer x)
Computes the in-place bitwise XOR of this container with another (symmetric difference).int
last()
Get the last integer held in the containerprotected MappeableContainer
lazyor(MappeableArrayContainer value2)
protected MappeableContainer
lazyor(MappeableBitmapContainer x)
protected MappeableContainer
lazyor(MappeableRunContainer x)
MappeableContainer
limit(int maxcardinality)
Create a new MappeableContainer containing at most maxcardinality integers.protected void
loadData(MappeableArrayContainer arrayContainer)
int
nextAbsentValue(short fromValue)
Gets the first absent value greater than or equal to the lower bound.int
nextClearBit(int i)
Find the index of the next clear bit greater or equal to i.int
nextSetBit(int i)
Find the index of the next set bit greater or equal to i, returns -1 if none found.int
nextValue(short fromValue)
Gets the first value greater than or equal to the lower bound, or -1 if no such value exists.MappeableContainer
not(int firstOfRange, int lastOfRange)
Computes the bitwise NOT of this container (complement).int
numberOfRunsAdjustment()
Computes the number of runsint
numberOfRunsLowerBound(int mustNotExceed)
Counts how many runs there is in the bitmap, up to a maximumMappeableContainer
or(MappeableArrayContainer value2)
Computes the bitwise OR of this container with another (union).MappeableContainer
or(MappeableBitmapContainer value2)
Computes the bitwise OR of this container with another (union).MappeableContainer
or(MappeableRunContainer value2)
Computes the bitwise OR of this container with another (union).int
prevClearBit(int i)
Find the index of the previous clear bit less than or equal to i.int
previousAbsentValue(short fromValue)
Gets the last value less than or equal to the upper bound.int
previousValue(short fromValue)
Gets the last value less than or equal to the upper bound, or -1 if no such value exists.int
prevSetBit(int i)
Find the index of the previous set bit less than or equal to i, returns -1 if none found.int
rank(short lowbits)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).void
readExternal(ObjectInput in)
MappeableContainer
remove(int begin, int end)
Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.MappeableContainer
remove(short i)
Remove the short from this container.MappeableContainer
repairAfterLazy()
The output of a lazyOR or lazyIOR might be an invalid container, this should be called on it.MappeableContainer
runOptimize()
Convert to MappeableRunContainers, when the result is smaller.short
select(int j)
Return the jth valueint
serializedSizeInBytes()
Report the number of bytes required to serialize this container.protected static int
serializedSizeInBytes(int unusedCardinality)
MappeableArrayContainer
toArrayContainer()
Copies the data to an array containerMappeableBitmapContainer
toBitmapContainer()
Convert the current container to a BitmapContainer, if a conversion is needed.Container
toContainer()
Convert to a non-mappeable container.long[]
toLongArray()
Create a copy of the content of this container as a long array.String
toString()
void
trim()
If possible, recover wasted memory.protected void
updateCardinality(int prevOnes, int newOnes)
protected void
writeArray(DataOutput out)
Write just the underlying array.protected void
writeArray(ByteBuffer buffer)
Write just the underlying array.void
writeExternal(ObjectOutput out)
MappeableContainer
xor(MappeableArrayContainer value2)
Computes the bitwise XOR of this container with another (symmetric difference).MappeableContainer
xor(MappeableBitmapContainer value2)
Computes the bitwise XOR of this container with another (symmetric difference).MappeableContainer
xor(MappeableRunContainer value2)
Computes the bitwise XOR of this container with another (symmetric difference).-
Methods inherited from class org.roaringbitmap.buffer.MappeableContainer
and, andCardinality, andNot, assertNonEmpty, contains, getContainerName, iand, iandNot, intersects, ior, ixor, lazyIOR, lazyOR, or, rangeOfOnes, xor, xorCardinality
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
MAX_CAPACITY
protected static final int MAX_CAPACITY
- See Also:
- Constant Field Values
-
USE_BRANCHLESS
public static final boolean USE_BRANCHLESS
optimization flag: whether the cardinality of the bitmaps is maintained through branchless operation- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MappeableBitmapContainer
public MappeableBitmapContainer()
Create a bitmap container with all bits set to false
-
MappeableBitmapContainer
public MappeableBitmapContainer(BitmapContainer bc)
Creates a new bitmap container from a non-mappeable one. This copies the data.- Parameters:
bc
- the original container
-
MappeableBitmapContainer
public MappeableBitmapContainer(int firstOfRun, int lastOfRun)
Create a bitmap container with a run of ones from firstOfRun to lastOfRun, inclusive caller must ensure that the range isn't so small that an ArrayContainer should have been created instead- Parameters:
firstOfRun
- first indexlastOfRun
- last index (range is exclusive)
-
MappeableBitmapContainer
public MappeableBitmapContainer(LongBuffer array, int initCardinality)
Construct a new BitmapContainer backed by the provided LongBuffer.- Parameters:
array
- LongBuffer where the data is storedinitCardinality
- cardinality (number of values stored)
-
-
Method Detail
-
serializedSizeInBytes
protected static int serializedSizeInBytes(int unusedCardinality)
-
add
public MappeableContainer add(int begin, int end)
Description copied from class:MappeableContainer
Return a new container with all shorts in [begin,end) added using an unsigned interpretation.- Specified by:
add
in classMappeableContainer
- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
add
public MappeableContainer add(short i)
Description copied from class:MappeableContainer
Add a short to the container. May generate a new container.- Specified by:
add
in interfaceWordStorage<MappeableContainer>
- Specified by:
add
in classMappeableContainer
- Parameters:
i
- short to be added- Returns:
- the new container
-
isEmpty
public boolean isEmpty()
Description copied from class:MappeableContainer
Checks whether the container is empty or not.- Specified by:
isEmpty
in interfaceWordStorage<MappeableContainer>
- Specified by:
isEmpty
in classMappeableContainer
- Returns:
- true if the container is empty.
-
and
public MappeableArrayContainer and(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Specified by:
and
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
and
public MappeableContainer and(MappeableBitmapContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Specified by:
and
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
and
public MappeableContainer and(MappeableRunContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Specified by:
and
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
andNot
public MappeableContainer andNot(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Specified by:
andNot
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
andNot
public MappeableContainer andNot(MappeableBitmapContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Specified by:
andNot
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
andNot
public MappeableContainer andNot(MappeableRunContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Specified by:
andNot
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
clear
public void clear()
Description copied from class:MappeableContainer
Empties the container- Specified by:
clear
in classMappeableContainer
-
clone
public MappeableBitmapContainer clone()
- Specified by:
clone
in classMappeableContainer
-
computeCardinality
protected void computeCardinality()
Recomputes the cardinality of the bitmap.
-
cardinalityInRange
protected int cardinalityInRange(int start, int end)
-
updateCardinality
protected void updateCardinality(int prevOnes, int newOnes)
-
contains
public boolean contains(short i)
Description copied from class:MappeableContainer
Checks whether the contain contains the provided value- Specified by:
contains
in classMappeableContainer
- Parameters:
i
- value to check- Returns:
- whether the value is in the container
-
bitValue
protected long bitValue(short i)
-
contains
public static boolean contains(ByteBuffer buf, int position, short i)
Checks whether the container contains the value i.- Parameters:
buf
- underlying bufferposition
- position of the container in the bufferi
- index- Returns:
- whether the container contains the value i
-
fillArray
protected void fillArray(short[] array)
Fill the array with set bits- Parameters:
array
- container (should be sufficiently large)
-
fillLeastSignificant16bits
public void fillLeastSignificant16bits(int[] x, int i, int mask)
Description copied from class:MappeableContainer
Fill the least significant 16 bits of the integer array, starting at index index, with the short values from this container. The caller is responsible to allocate enough room. The most significant 16 bits of each integer are given by the most significant bits of the provided mask.- Specified by:
fillLeastSignificant16bits
in classMappeableContainer
- Parameters:
x
- provided arrayi
- starting indexmask
- indicates most significant bits
-
flip
public MappeableContainer flip(short i)
Description copied from class:MappeableContainer
Add a short to the container if it is not present, otherwise remove it. May generate a new container.- Specified by:
flip
in classMappeableContainer
- Parameters:
i
- short to be added- Returns:
- the new container
-
getArraySizeInBytes
protected int getArraySizeInBytes()
Description copied from class:MappeableContainer
Size of the underlying array- Specified by:
getArraySizeInBytes
in classMappeableContainer
- Returns:
- size in bytes
-
getCardinality
public int getCardinality()
Description copied from class:MappeableContainer
Computes the distinct number of short values in the container. Can be expected to run in constant time.- Specified by:
getCardinality
in classMappeableContainer
- Returns:
- the cardinality
-
getReverseShortIterator
public ShortIterator getReverseShortIterator()
Description copied from class:MappeableContainer
Iterator to visit the short values in the container in descending order.- Specified by:
getReverseShortIterator
in classMappeableContainer
- Returns:
- iterator
-
getShortIterator
public PeekableShortIterator getShortIterator()
Description copied from class:MappeableContainer
Iterator to visit the short values in the container in ascending order.- Specified by:
getShortIterator
in classMappeableContainer
- Returns:
- iterator
-
getBatchIterator
public ContainerBatchIterator getBatchIterator()
Description copied from class:MappeableContainer
Gets an iterator to visit the contents of the container in batches- Specified by:
getBatchIterator
in classMappeableContainer
- Returns:
- iterator
-
getSizeInBytes
public int getSizeInBytes()
Description copied from class:MappeableContainer
Computes an estimate of the memory usage of this container. The estimate is not meant to be exact.- Specified by:
getSizeInBytes
in classMappeableContainer
- Returns:
- estimated memory usage in bytes
-
iadd
public MappeableContainer iadd(int begin, int end)
Description copied from class:MappeableContainer
Add all shorts in [begin,end) using an unsigned interpretation. May generate a new container.- Specified by:
iadd
in classMappeableContainer
- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
iand
public MappeableContainer iand(MappeableArrayContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise AND of this container with another (intersection). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iand
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
iand
public MappeableContainer iand(MappeableBitmapContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise AND of this container with another (intersection). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iand
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
iand
public MappeableContainer iand(MappeableRunContainer x)
Description copied from class:MappeableContainer
Computes the in-place bitwise AND of this container with another (intersection). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iand
in classMappeableContainer
- Parameters:
x
- other container- Returns:
- aggregated container
-
iandNot
public MappeableContainer iandNot(MappeableArrayContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise ANDNOT of this container with another (difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iandNot
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
iandNot
public MappeableContainer iandNot(MappeableBitmapContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise ANDNOT of this container with another (difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iandNot
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
iandNot
public MappeableContainer iandNot(MappeableRunContainer x)
Description copied from class:MappeableContainer
Computes the in-place bitwise ANDNOT of this container with another (difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
iandNot
in classMappeableContainer
- Parameters:
x
- other container- Returns:
- aggregated container
-
ilazyor
protected MappeableContainer ilazyor(MappeableArrayContainer value2)
-
ilazyor
protected MappeableContainer ilazyor(MappeableBitmapContainer x)
-
ilazyor
protected MappeableContainer ilazyor(MappeableRunContainer x)
-
inot
public MappeableContainer inot(int firstOfRange, int lastOfRange)
Description copied from class:MappeableContainer
Computes the in-place bitwise NOT of this container (complement). Only those bits within the range are affected. The current container is generally modified. May generate a new container.- Specified by:
inot
in classMappeableContainer
- Parameters:
firstOfRange
- beginning of range (inclusive); 0 is beginning of this container.lastOfRange
- ending of range (exclusive)- Returns:
- (partially) completmented container
-
intersects
public boolean intersects(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Returns true if the current container intersects the other container.- Specified by:
intersects
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- whether they intersect
-
intersects
public boolean intersects(MappeableBitmapContainer value2)
Description copied from class:MappeableContainer
Returns true if the current container intersects the other container.- Specified by:
intersects
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- whether they intersect
-
intersects
public boolean intersects(MappeableRunContainer x)
Description copied from class:MappeableContainer
Returns true if the current container intersects the other container.- Specified by:
intersects
in classMappeableContainer
- Parameters:
x
- other container- Returns:
- whether they intersect
-
ior
public MappeableBitmapContainer ior(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the in-place bitwise OR of this container with another (union). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ior
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
ior
public MappeableContainer ior(MappeableBitmapContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise OR of this container with another (union). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ior
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
isFull
protected boolean isFull()
-
ior
public MappeableContainer ior(MappeableRunContainer x)
Description copied from class:MappeableContainer
Computes the in-place bitwise OR of this container with another (union). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ior
in classMappeableContainer
- Parameters:
x
- other container- Returns:
- aggregated container
-
iremove
public MappeableContainer iremove(int begin, int end)
Description copied from class:MappeableContainer
Remove shorts in [begin,end) using an unsigned interpretation. May generate a new container.- Specified by:
iremove
in classMappeableContainer
- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
isArrayBacked
protected boolean isArrayBacked()
- Specified by:
isArrayBacked
in classMappeableContainer
-
ixor
public MappeableContainer ixor(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the in-place bitwise XOR of this container with another (symmetric difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ixor
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
ixor
public MappeableContainer ixor(MappeableBitmapContainer b2)
Description copied from class:MappeableContainer
Computes the in-place bitwise XOR of this container with another (symmetric difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ixor
in classMappeableContainer
- Parameters:
b2
- other container- Returns:
- aggregated container
-
ixor
public MappeableContainer ixor(MappeableRunContainer x)
Description copied from class:MappeableContainer
Computes the in-place bitwise XOR of this container with another (symmetric difference). The current container is generally modified, whereas the provided container (x) is unaffected. May generate a new container.- Specified by:
ixor
in classMappeableContainer
- Parameters:
x
- other container- Returns:
- aggregated container
-
lazyor
protected MappeableContainer lazyor(MappeableArrayContainer value2)
-
lazyor
protected MappeableContainer lazyor(MappeableBitmapContainer x)
-
lazyor
protected MappeableContainer lazyor(MappeableRunContainer x)
-
limit
public MappeableContainer limit(int maxcardinality)
Description copied from class:MappeableContainer
Create a new MappeableContainer containing at most maxcardinality integers.- Specified by:
limit
in classMappeableContainer
- Parameters:
maxcardinality
- maximal cardinality- Returns:
- a new bitmap with cardinality no more than maxcardinality
-
loadData
protected void loadData(MappeableArrayContainer arrayContainer)
-
nextSetBit
public int nextSetBit(int i)
Find the index of the next set bit greater or equal to i, returns -1 if none found.- Parameters:
i
- starting index- Returns:
- index of the next set bit
-
nextClearBit
public int nextClearBit(int i)
Find the index of the next clear bit greater or equal to i.- Parameters:
i
- starting index- Returns:
- index of the next clear bit
-
not
public MappeableContainer not(int firstOfRange, int lastOfRange)
Description copied from class:MappeableContainer
Computes the bitwise NOT of this container (complement). Only those bits within the range are affected. The current container is left unaffected.- Specified by:
not
in classMappeableContainer
- Parameters:
firstOfRange
- beginning of range (inclusive); 0 is beginning of this container.lastOfRange
- ending of range (exclusive)- Returns:
- (partially) completmented container
-
numberOfRunsAdjustment
public int numberOfRunsAdjustment()
Computes the number of runs- Returns:
- the number of runs
-
numberOfRunsLowerBound
public int numberOfRunsLowerBound(int mustNotExceed)
Counts how many runs there is in the bitmap, up to a maximum- Parameters:
mustNotExceed
- maximum of runs beyond which counting is pointless- Returns:
- estimated number of courses
-
or
public MappeableContainer or(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Specified by:
or
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
or
public MappeableContainer or(MappeableBitmapContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Specified by:
or
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
or
public MappeableContainer or(MappeableRunContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Specified by:
or
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
prevSetBit
public int prevSetBit(int i)
Find the index of the previous set bit less than or equal to i, returns -1 if none found.- Parameters:
i
- starting index- Returns:
- index of the previous set bit
-
prevClearBit
public int prevClearBit(int i)
Find the index of the previous clear bit less than or equal to i.- Parameters:
i
- starting index- Returns:
- index of the previous clear bit
-
rank
public int rank(short lowbits)
Description copied from class:MappeableContainer
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).- Specified by:
rank
in classMappeableContainer
- Parameters:
lowbits
- upper limit- Returns:
- the rank
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
remove
public MappeableContainer remove(int begin, int end)
Description copied from class:MappeableContainer
Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.- Specified by:
remove
in classMappeableContainer
- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
remove
public MappeableContainer remove(short i)
Description copied from class:MappeableContainer
Remove the short from this container. May create a new container.- Specified by:
remove
in classMappeableContainer
- Parameters:
i
- to be removed- Returns:
- New container
-
repairAfterLazy
public MappeableContainer repairAfterLazy()
Description copied from class:MappeableContainer
The output of a lazyOR or lazyIOR might be an invalid container, this should be called on it.- Specified by:
repairAfterLazy
in classMappeableContainer
- Returns:
- a new valid container
-
runOptimize
public MappeableContainer runOptimize()
Description copied from class:MappeableContainer
Convert to MappeableRunContainers, when the result is smaller. Overridden by MappeableRunContainer to possibly switch from MappeableRunContainer to a smaller alternative.- Specified by:
runOptimize
in interfaceWordStorage<MappeableContainer>
- Specified by:
runOptimize
in classMappeableContainer
- Returns:
- the new container
-
select
public short select(int j)
Description copied from class:MappeableContainer
Return the jth value- Specified by:
select
in classMappeableContainer
- Parameters:
j
- index of the value- Returns:
- the value
-
serializedSizeInBytes
public int serializedSizeInBytes()
Description copied from class:MappeableContainer
Report the number of bytes required to serialize this container.- Specified by:
serializedSizeInBytes
in classMappeableContainer
- Returns:
- the size in bytes
-
toArrayContainer
public MappeableArrayContainer toArrayContainer()
Copies the data to an array container- Returns:
- the array container
-
toContainer
public Container toContainer()
Description copied from class:MappeableContainer
Convert to a non-mappeable container.- Specified by:
toContainer
in classMappeableContainer
- Returns:
- the non-mappeable container
-
toLongArray
public long[] toLongArray()
Create a copy of the content of this container as a long array. This creates a copy.- Returns:
- copy of the content as a long array
-
trim
public void trim()
Description copied from class:MappeableContainer
If possible, recover wasted memory.- Specified by:
trim
in classMappeableContainer
-
writeArray
protected void writeArray(DataOutput out) throws IOException
Description copied from class:MappeableContainer
Write just the underlying array.- Specified by:
writeArray
in classMappeableContainer
- Parameters:
out
- output stream- Throws:
IOException
- in case of failure
-
writeArray
protected void writeArray(ByteBuffer buffer)
Description copied from class:MappeableContainer
Write just the underlying array.- Specified by:
writeArray
in classMappeableContainer
- Parameters:
buffer
- the buffer to write to
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
xor
public MappeableContainer xor(MappeableArrayContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Specified by:
xor
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
xor
public MappeableContainer xor(MappeableBitmapContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Specified by:
xor
in classMappeableContainer
- Parameters:
value2
- other container- Returns:
- aggregated container
-
xor
public MappeableContainer xor(MappeableRunContainer value2)
Description copied from class:MappeableContainer
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Specified by:
xor
in classMappeableContainer
- Parameters:
value2
- other parameter- Returns:
- aggregated container
-
forEach
public void forEach(short msb, IntConsumer ic)
Description copied from class:MappeableContainer
Iterate through the values of this container and pass them along to the IntConsumer, using msb as the 16 most significant bits.- Specified by:
forEach
in classMappeableContainer
- Parameters:
msb
- 16 most significant bitsic
- consumer
-
andCardinality
public int andCardinality(MappeableArrayContainer value2)
- Specified by:
andCardinality
in classMappeableContainer
-
andCardinality
public int andCardinality(MappeableBitmapContainer value2)
- Specified by:
andCardinality
in classMappeableContainer
-
andCardinality
public int andCardinality(MappeableRunContainer x)
- Specified by:
andCardinality
in classMappeableContainer
-
toBitmapContainer
public MappeableBitmapContainer toBitmapContainer()
Description copied from class:MappeableContainer
Convert the current container to a BitmapContainer, if a conversion is needed. If the container is already a bitmap, the container is returned unchanged.- Specified by:
toBitmapContainer
in classMappeableContainer
- Returns:
- a bitmap container
-
first
public int first()
Description copied from class:MappeableContainer
Get the first integer held in the container- Specified by:
first
in classMappeableContainer
- Returns:
- the first integer in the container
-
last
public int last()
Description copied from class:MappeableContainer
Get the last integer held in the container- Specified by:
last
in classMappeableContainer
- Returns:
- the last integer in the container
-
nextValue
public int nextValue(short fromValue)
Description copied from class:MappeableContainer
Gets the first value greater than or equal to the lower bound, or -1 if no such value exists.- Specified by:
nextValue
in classMappeableContainer
- Parameters:
fromValue
- the lower bound (inclusive)- Returns:
- the next value
-
previousValue
public int previousValue(short fromValue)
Description copied from class:MappeableContainer
Gets the last value less than or equal to the upper bound, or -1 if no such value exists.- Specified by:
previousValue
in classMappeableContainer
- Parameters:
fromValue
- the upper bound (inclusive)- Returns:
- the previous value
-
nextAbsentValue
public int nextAbsentValue(short fromValue)
Description copied from class:MappeableContainer
Gets the first absent value greater than or equal to the lower bound.- Specified by:
nextAbsentValue
in classMappeableContainer
- Parameters:
fromValue
- the lower bound (inclusive)- Returns:
- the next absent value
-
previousAbsentValue
public int previousAbsentValue(short fromValue)
Description copied from class:MappeableContainer
Gets the last value less than or equal to the upper bound.- Specified by:
previousAbsentValue
in classMappeableContainer
- Parameters:
fromValue
- the upper bound (inclusive)- Returns:
- the previous absent value
-
contains
protected boolean contains(MappeableBitmapContainer bitmapContainer)
- Specified by:
contains
in classMappeableContainer
-
intersects
public boolean intersects(int minimum, int supremum)
Description copied from class:MappeableContainer
Checks if the container intersects with a range- Specified by:
intersects
in classMappeableContainer
- Parameters:
minimum
- the inclusive unsigned lower bound of the rangesupremum
- the exclusive unsigned upper bound of the range- Returns:
- true if the container intersects the range
-
contains
public boolean contains(int minimum, int supremum)
Description copied from class:MappeableContainer
Checks whether the container contains the entire range- Specified by:
contains
in classMappeableContainer
- Parameters:
minimum
- the inclusive lower bound of the rangesupremum
- the exclusive upper bound of the range- Returns:
- true if the container contains the range
-
contains
protected boolean contains(MappeableRunContainer runContainer)
- Specified by:
contains
in classMappeableContainer
-
contains
protected boolean contains(MappeableArrayContainer arrayContainer)
- Specified by:
contains
in classMappeableContainer
-
-