Package org.roaringbitmap.buffer
Class MappeableContainer
- java.lang.Object
-
- org.roaringbitmap.buffer.MappeableContainer
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Iterable<Short>
,WordStorage<MappeableContainer>
- Direct Known Subclasses:
MappeableArrayContainer
,MappeableBitmapContainer
,MappeableRunContainer
public abstract class MappeableContainer extends Object implements Iterable<Short>, Cloneable, Externalizable, WordStorage<MappeableContainer>
Base container class. This class is similar to org.roaringbitmap.Container but meant to be used with memory mapping.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
ContainerNames
Name of the various possible containers
-
Constructor Summary
Constructors Constructor Description MappeableContainer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract MappeableContainer
add(int begin, int end)
Return a new container with all shorts in [begin,end) added using an unsigned interpretation.abstract MappeableContainer
add(short x)
Add a short to the container.abstract MappeableContainer
and(MappeableArrayContainer x)
Computes the bitwise AND of this container with another (intersection).abstract MappeableContainer
and(MappeableBitmapContainer x)
Computes the bitwise AND of this container with another (intersection).protected MappeableContainer
and(MappeableContainer x)
abstract MappeableContainer
and(MappeableRunContainer x)
Computes the bitwise AND of this container with another (intersection).protected abstract int
andCardinality(MappeableArrayContainer x)
protected abstract int
andCardinality(MappeableBitmapContainer x)
int
andCardinality(MappeableContainer x)
Computes the bitwise AND of this container with another (intersection).protected abstract int
andCardinality(MappeableRunContainer x)
abstract MappeableContainer
andNot(MappeableArrayContainer x)
Computes the bitwise ANDNOT of this container with another (difference).abstract MappeableContainer
andNot(MappeableBitmapContainer x)
Computes the bitwise ANDNOT of this container with another (difference).protected MappeableContainer
andNot(MappeableContainer x)
abstract MappeableContainer
andNot(MappeableRunContainer x)
Computes the bitwise ANDNOT of this container with another (difference).protected void
assertNonEmpty(boolean condition)
Throw if the container is emptyabstract void
clear()
Empties the containerabstract MappeableContainer
clone()
abstract boolean
contains(int minimum, int supremum)
Checks whether the container contains the entire rangeabstract boolean
contains(short x)
Checks whether the contain contains the provided valueprotected abstract boolean
contains(MappeableArrayContainer arrayContainer)
protected abstract boolean
contains(MappeableBitmapContainer bitmapContainer)
boolean
contains(MappeableContainer subset)
Checks whether the container is a subset of this container or notprotected abstract boolean
contains(MappeableRunContainer runContainer)
abstract void
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.abstract int
first()
Get the first integer held in the containerabstract MappeableContainer
flip(short x)
Add a short to the container if it is not present, otherwise remove it.abstract 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 abstract int
getArraySizeInBytes()
Size of the underlying arrayabstract ContainerBatchIterator
getBatchIterator()
Gets an iterator to visit the contents of the container in batchesabstract int
getCardinality()
Computes the distinct number of short values in the container.String
getContainerName()
Get the name of this container.abstract ShortIterator
getReverseShortIterator()
Iterator to visit the short values in the container in descending order.abstract PeekableShortIterator
getShortIterator()
Iterator to visit the short values in the container in ascending order.abstract int
getSizeInBytes()
Computes an estimate of the memory usage of this container.abstract MappeableContainer
iadd(int begin, int end)
Add all shorts in [begin,end) using an unsigned interpretation.abstract MappeableContainer
iand(MappeableArrayContainer x)
Computes the in-place bitwise AND of this container with another (intersection).abstract MappeableContainer
iand(MappeableBitmapContainer x)
Computes the in-place bitwise AND of this container with another (intersection).protected MappeableContainer
iand(MappeableContainer x)
abstract MappeableContainer
iand(MappeableRunContainer x)
Computes the in-place bitwise AND of this container with another (intersection).abstract MappeableContainer
iandNot(MappeableArrayContainer x)
Computes the in-place bitwise ANDNOT of this container with another (difference).abstract MappeableContainer
iandNot(MappeableBitmapContainer x)
Computes the in-place bitwise ANDNOT of this container with another (difference).protected MappeableContainer
iandNot(MappeableContainer x)
abstract MappeableContainer
iandNot(MappeableRunContainer x)
Computes the in-place bitwise ANDNOT of this container with another (difference).abstract MappeableContainer
inot(int rangeStart, int rangeEnd)
Computes the in-place bitwise NOT of this container (complement).abstract boolean
intersects(int minimum, int supremum)
Checks if the container intersects with a rangeabstract boolean
intersects(MappeableArrayContainer x)
Returns true if the current container intersects the other container.abstract boolean
intersects(MappeableBitmapContainer x)
Returns true if the current container intersects the other container.boolean
intersects(MappeableContainer x)
Returns true if the current container intersects the other container.abstract boolean
intersects(MappeableRunContainer x)
Returns true if the current container intersects the other container.abstract MappeableContainer
ior(MappeableArrayContainer x)
Computes the in-place bitwise OR of this container with another (union).abstract MappeableContainer
ior(MappeableBitmapContainer x)
Computes the in-place bitwise OR of this container with another (union).protected MappeableContainer
ior(MappeableContainer x)
abstract MappeableContainer
ior(MappeableRunContainer x)
Computes the in-place bitwise OR of this container with another (union).abstract MappeableContainer
iremove(int begin, int end)
Remove shorts in [begin,end) using an unsigned interpretation.protected abstract boolean
isArrayBacked()
abstract boolean
isEmpty()
Checks whether the container is empty or not.abstract MappeableContainer
ixor(MappeableArrayContainer x)
Computes the in-place bitwise XOR of this container with another (symmetric difference).abstract MappeableContainer
ixor(MappeableBitmapContainer x)
Computes the in-place bitwise XOR of this container with another (symmetric difference).protected MappeableContainer
ixor(MappeableContainer x)
abstract MappeableContainer
ixor(MappeableRunContainer x)
Computes the in-place bitwise XOR of this container with another (symmetric difference).abstract int
last()
Get the last integer held in the containerMappeableContainer
lazyIOR(MappeableContainer x)
Computes the in-place bitwise OR of this container with another (union).MappeableContainer
lazyOR(MappeableContainer x)
Computes the bitwise OR of this container with another (union).abstract MappeableContainer
limit(int maxcardinality)
Create a new MappeableContainer containing at most maxcardinality integers.abstract int
nextAbsentValue(short fromValue)
Gets the first absent value greater than or equal to the lower bound.abstract int
nextValue(short fromValue)
Gets the first value greater than or equal to the lower bound, or -1 if no such value exists.abstract MappeableContainer
not(int rangeStart, int rangeEnd)
Computes the bitwise NOT of this container (complement).abstract MappeableContainer
or(MappeableArrayContainer x)
Computes the bitwise OR of this container with another (union).abstract MappeableContainer
or(MappeableBitmapContainer x)
Computes the bitwise OR of this container with another (union).protected MappeableContainer
or(MappeableContainer x)
abstract MappeableContainer
or(MappeableRunContainer x)
Computes the bitwise OR of this container with another (union).abstract int
previousAbsentValue(short fromValue)
Gets the last value less than or equal to the upper bound.abstract int
previousValue(short fromValue)
Gets the last value less than or equal to the upper bound, or -1 if no such value exists.static MappeableContainer
rangeOfOnes(int start, int last)
Create a container initialized with a range of consecutive valuesabstract int
rank(short lowbits)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).abstract MappeableContainer
remove(int begin, int end)
Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.abstract MappeableContainer
remove(short x)
Remove the short from this container.abstract MappeableContainer
repairAfterLazy()
The output of a lazyOR or lazyIOR might be an invalid container, this should be called on it.abstract MappeableContainer
runOptimize()
Convert to MappeableRunContainers, when the result is smaller.abstract short
select(int j)
Return the jth valueabstract int
serializedSizeInBytes()
Report the number of bytes required to serialize this container.abstract MappeableBitmapContainer
toBitmapContainer()
Convert the current container to a BitmapContainer, if a conversion is needed.abstract Container
toContainer()
Convert to a non-mappeable container.abstract void
trim()
If possible, recover wasted memory.protected abstract void
writeArray(DataOutput out)
Write just the underlying array.protected abstract void
writeArray(ByteBuffer buffer)
Write just the underlying array.abstract MappeableContainer
xor(MappeableArrayContainer x)
Computes the bitwise XOR of this container with another (symmetric difference).abstract MappeableContainer
xor(MappeableBitmapContainer x)
Computes the bitwise XOR of this container with another (symmetric difference).protected MappeableContainer
xor(MappeableContainer x)
abstract MappeableContainer
xor(MappeableRunContainer x)
Computes the bitwise XOR of this container with another (symmetric difference).int
xorCardinality(MappeableContainer other)
Returns the cardinality of the XOR between the passed container and this container without materialising a temporary container.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
ContainerNames
public static String[] ContainerNames
Name of the various possible containers
-
-
Method Detail
-
rangeOfOnes
public static MappeableContainer rangeOfOnes(int start, int last)
Create a container initialized with a range of consecutive values- Parameters:
start
- first indexlast
- last index (range is exclusive)- Returns:
- a new container initialized with the specified values
-
add
public abstract MappeableContainer add(int begin, int end)
Return a new container with all shorts in [begin,end) added using an unsigned interpretation.- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
add
public abstract MappeableContainer add(short x)
Add a short to the container. May generate a new container.- Specified by:
add
in interfaceWordStorage<MappeableContainer>
- Parameters:
x
- short to be added- Returns:
- the new container
-
isEmpty
public abstract boolean isEmpty()
Checks whether the container is empty or not.- Specified by:
isEmpty
in interfaceWordStorage<MappeableContainer>
- Returns:
- true if the container is empty.
-
and
public abstract MappeableContainer and(MappeableArrayContainer x)
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
and
public abstract MappeableContainer and(MappeableBitmapContainer x)
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
and
protected MappeableContainer and(MappeableContainer x)
-
andCardinality
protected abstract int andCardinality(MappeableArrayContainer x)
-
andCardinality
protected abstract int andCardinality(MappeableBitmapContainer x)
-
andCardinality
protected abstract int andCardinality(MappeableRunContainer x)
-
xorCardinality
public int xorCardinality(MappeableContainer other)
Returns the cardinality of the XOR between the passed container and this container without materialising a temporary container.- Parameters:
other
- other container- Returns:
- the cardinality of the symmetric difference of the two containers
-
andCardinality
public int andCardinality(MappeableContainer x)
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
and
public abstract MappeableContainer and(MappeableRunContainer x)
Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
andNot
public abstract MappeableContainer andNot(MappeableArrayContainer x)
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
andNot
public abstract MappeableContainer andNot(MappeableBitmapContainer x)
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
andNot
protected MappeableContainer andNot(MappeableContainer x)
-
andNot
public abstract MappeableContainer andNot(MappeableRunContainer x)
Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
clear
public abstract void clear()
Empties the container
-
clone
public abstract MappeableContainer clone()
-
contains
public abstract boolean contains(short x)
Checks whether the contain contains the provided value- Parameters:
x
- value to check- Returns:
- whether the value is in the container
-
contains
public boolean contains(MappeableContainer subset)
Checks whether the container is a subset of this container or not- Parameters:
subset
- the container to be tested- Returns:
- true if the parameter is a subset of this container
-
contains
protected abstract boolean contains(MappeableRunContainer runContainer)
-
contains
protected abstract boolean contains(MappeableArrayContainer arrayContainer)
-
contains
protected abstract boolean contains(MappeableBitmapContainer bitmapContainer)
-
intersects
public abstract boolean intersects(int minimum, int supremum)
Checks if the container intersects with a range- 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 abstract boolean contains(int minimum, int supremum)
Checks whether the container contains the entire range- Parameters:
minimum
- the inclusive lower bound of the rangesupremum
- the exclusive upper bound of the range- Returns:
- true if the container contains the range
-
fillLeastSignificant16bits
public abstract void 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. 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.- Parameters:
x
- provided arrayi
- starting indexmask
- indicates most significant bits
-
flip
public abstract MappeableContainer flip(short x)
Add a short to the container if it is not present, otherwise remove it. May generate a new container.- Parameters:
x
- short to be added- Returns:
- the new container
-
getArraySizeInBytes
protected abstract int getArraySizeInBytes()
Size of the underlying array- Returns:
- size in bytes
-
getCardinality
public abstract int getCardinality()
Computes the distinct number of short values in the container. Can be expected to run in constant time.- Returns:
- the cardinality
-
getContainerName
public String getContainerName()
Get the name of this container.- Returns:
- name of the container
-
getReverseShortIterator
public abstract ShortIterator getReverseShortIterator()
Iterator to visit the short values in the container in descending order.- Returns:
- iterator
-
getShortIterator
public abstract PeekableShortIterator getShortIterator()
Iterator to visit the short values in the container in ascending order.- Returns:
- iterator
-
getBatchIterator
public abstract ContainerBatchIterator getBatchIterator()
Gets an iterator to visit the contents of the container in batches- Returns:
- iterator
-
forEach
public abstract 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.- Parameters:
msb
- 16 most significant bitsic
- consumer
-
getSizeInBytes
public abstract int getSizeInBytes()
Computes an estimate of the memory usage of this container. The estimate is not meant to be exact.- Returns:
- estimated memory usage in bytes
-
iadd
public abstract MappeableContainer iadd(int begin, int end)
Add all shorts in [begin,end) using an unsigned interpretation. May generate a new container.- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
iand
public abstract MappeableContainer iand(MappeableArrayContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iand
public abstract MappeableContainer iand(MappeableBitmapContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iand
protected MappeableContainer iand(MappeableContainer x)
-
iand
public abstract MappeableContainer iand(MappeableRunContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iandNot
public abstract MappeableContainer iandNot(MappeableArrayContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iandNot
public abstract MappeableContainer iandNot(MappeableBitmapContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iandNot
protected MappeableContainer iandNot(MappeableContainer x)
-
iandNot
public abstract MappeableContainer iandNot(MappeableRunContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
inot
public abstract MappeableContainer inot(int rangeStart, int rangeEnd)
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.- Parameters:
rangeStart
- beginning of range (inclusive); 0 is beginning of this container.rangeEnd
- ending of range (exclusive)- Returns:
- (partially) completmented container
-
intersects
public abstract boolean intersects(MappeableArrayContainer x)
Returns true if the current container intersects the other container.- Parameters:
x
- other container- Returns:
- whether they intersect
-
intersects
public abstract boolean intersects(MappeableBitmapContainer x)
Returns true if the current container intersects the other container.- Parameters:
x
- other container- Returns:
- whether they intersect
-
intersects
public boolean intersects(MappeableContainer x)
Returns true if the current container intersects the other container.- Parameters:
x
- other container- Returns:
- whether they intersect
-
intersects
public abstract boolean intersects(MappeableRunContainer x)
Returns true if the current container intersects the other container.- Parameters:
x
- other container- Returns:
- whether they intersect
-
ior
public abstract MappeableContainer ior(MappeableArrayContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
ior
public abstract MappeableContainer ior(MappeableBitmapContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
ior
protected MappeableContainer ior(MappeableContainer x)
-
ior
public abstract MappeableContainer ior(MappeableRunContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
iremove
public abstract MappeableContainer iremove(int begin, int end)
Remove shorts in [begin,end) using an unsigned interpretation. May generate a new container.- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
isArrayBacked
protected abstract boolean isArrayBacked()
-
ixor
public abstract MappeableContainer ixor(MappeableArrayContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
ixor
public abstract MappeableContainer ixor(MappeableBitmapContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
ixor
protected MappeableContainer ixor(MappeableContainer x)
-
ixor
public abstract MappeableContainer ixor(MappeableRunContainer x)
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.- Parameters:
x
- other container- Returns:
- aggregated container
-
lazyIOR
public MappeableContainer lazyIOR(MappeableContainer x)
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. The resulting container may not track its cardinality correctly. The resulting container may not track its cardinality correctly. This can be fixed as follows: if(c.getCardinality()<0) ((MappeableBitmapContainer)c).computeCardinality();- Parameters:
x
- other container- Returns:
- aggregated container
-
lazyOR
public MappeableContainer lazyOR(MappeableContainer x)
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected. The resulting container may not track its cardinality correctly. This can be fixed as follows: if(c.getCardinality()<0) ((MappeableBitmapContainer)c).computeCardinality();- Parameters:
x
- other container- Returns:
- aggregated container
-
limit
public abstract MappeableContainer limit(int maxcardinality)
Create a new MappeableContainer containing at most maxcardinality integers.- Parameters:
maxcardinality
- maximal cardinality- Returns:
- a new bitmap with cardinality no more than maxcardinality
-
not
public abstract MappeableContainer not(int rangeStart, int rangeEnd)
Computes the bitwise NOT of this container (complement). Only those bits within the range are affected. The current container is left unaffected.- Parameters:
rangeStart
- beginning of range (inclusive); 0 is beginning of this container.rangeEnd
- ending of range (exclusive)- Returns:
- (partially) completmented container
-
or
public abstract MappeableContainer or(MappeableArrayContainer x)
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
or
public abstract MappeableContainer or(MappeableBitmapContainer x)
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
or
protected MappeableContainer or(MappeableContainer x)
-
or
public abstract MappeableContainer or(MappeableRunContainer x)
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
rank
public abstract int rank(short lowbits)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).- Parameters:
lowbits
- upper limit- Returns:
- the rank
-
remove
public abstract MappeableContainer remove(int begin, int end)
Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.- Parameters:
begin
- start of range (inclusive)end
- end of range (exclusive)- Returns:
- the new container
-
remove
public abstract MappeableContainer remove(short x)
Remove the short from this container. May create a new container.- Parameters:
x
- to be removed- Returns:
- New container
-
repairAfterLazy
public abstract MappeableContainer repairAfterLazy()
The output of a lazyOR or lazyIOR might be an invalid container, this should be called on it.- Returns:
- a new valid container
-
runOptimize
public abstract MappeableContainer runOptimize()
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>
- Returns:
- the new container
-
select
public abstract short select(int j)
Return the jth value- Parameters:
j
- index of the value- Returns:
- the value
-
serializedSizeInBytes
public abstract int serializedSizeInBytes()
Report the number of bytes required to serialize this container.- Returns:
- the size in bytes
-
toContainer
public abstract Container toContainer()
Convert to a non-mappeable container.- Returns:
- the non-mappeable container
-
trim
public abstract void trim()
If possible, recover wasted memory.
-
writeArray
protected abstract void writeArray(DataOutput out) throws IOException
Write just the underlying array.- Parameters:
out
- output stream- Throws:
IOException
- in case of failure
-
writeArray
protected abstract void writeArray(ByteBuffer buffer)
Write just the underlying array.- Parameters:
buffer
- the buffer to write to
-
xor
public abstract MappeableContainer xor(MappeableArrayContainer x)
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
xor
public abstract MappeableContainer xor(MappeableBitmapContainer x)
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other container- Returns:
- aggregated container
-
xor
protected MappeableContainer xor(MappeableContainer x)
-
xor
public abstract MappeableContainer xor(MappeableRunContainer x)
Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.- Parameters:
x
- other parameter- Returns:
- aggregated container
-
toBitmapContainer
public abstract MappeableBitmapContainer toBitmapContainer()
Convert the current container to a BitmapContainer, if a conversion is needed. If the container is already a bitmap, the container is returned unchanged.- Returns:
- a bitmap container
-
first
public abstract int first()
Get the first integer held in the container- Returns:
- the first integer in the container
- Throws:
NoSuchElementException
- if empty
-
last
public abstract int last()
Get the last integer held in the container- Returns:
- the last integer in the container
- Throws:
NoSuchElementException
- if empty
-
nextValue
public abstract int nextValue(short fromValue)
Gets the first value greater than or equal to the lower bound, or -1 if no such value exists.- Parameters:
fromValue
- the lower bound (inclusive)- Returns:
- the next value
-
previousValue
public abstract int previousValue(short fromValue)
Gets the last value less than or equal to the upper bound, or -1 if no such value exists.- Parameters:
fromValue
- the upper bound (inclusive)- Returns:
- the previous value
-
nextAbsentValue
public abstract int nextAbsentValue(short fromValue)
Gets the first absent value greater than or equal to the lower bound.- Parameters:
fromValue
- the lower bound (inclusive)- Returns:
- the next absent value
-
previousAbsentValue
public abstract int previousAbsentValue(short fromValue)
Gets the last value less than or equal to the upper bound.- Parameters:
fromValue
- the upper bound (inclusive)- Returns:
- the previous absent value
-
assertNonEmpty
protected void assertNonEmpty(boolean condition)
Throw if the container is empty- Parameters:
condition
- a boolean expression- Throws:
NoSuchElementException
- if empty
-
-