org.roaringbitmap.buffer
Class BitmapContainer

java.lang.Object
  extended by org.roaringbitmap.buffer.Container
      extended by org.roaringbitmap.buffer.BitmapContainer
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Iterable<Short>

public final class BitmapContainer
extends Container
implements Cloneable, Serializable

Simple bitset-like container. Unlike org.roaringbitmap.BitmapContainer, this class uses a LongBuffer to store data.

See Also:
Serialized Form

Field Summary
protected static int maxcapacity
           
 
Constructor Summary
BitmapContainer()
          Create a bitmap container with all bits set to false
BitmapContainer(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
BitmapContainer(LongBuffer array, int cardinality)
          Construct a new BitmapContainer backed by the provided LongBuffer.
 
Method Summary
 Container add(short i)
          Add a short to the container.
 ArrayContainer and(ArrayContainer value2)
          Computes the bitwise AND of this container with another (intersection).
 Container and(BitmapContainer value2)
          Computes the bitwise AND of this container with another (intersection).
 Container andNot(ArrayContainer value2)
          Computes the bitwise ANDNOT of this container with another (difference).
 Container andNot(BitmapContainer value2)
          Computes the bitwise ANDNOT of this container with another (difference).
 void clear()
          Empties the container
 BitmapContainer clone()
           
 boolean contains(short i)
          Checks whether the contain contains the provided value
 boolean equals(Object o)
           
protected  void fillArray(short[] array)
          Fill the array with set bits
 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.
protected  int getArraySizeInBytes()
          Size of the underlying array
 int getCardinality()
          Computes the distinct number of short values in the container.
 ShortIterator getShortIterator()
          Iterator to visit the short values in the container
 int getSizeInBytes()
          Computes an estimate of the memory usage of this container.
 int hashCode()
           
 Container iand(ArrayContainer B2)
          Computes the in-place bitwise AND of this container with another (intersection).
 Container iand(BitmapContainer B2)
          Computes the in-place bitwise AND of this container with another (intersection).
 Container iandNot(ArrayContainer B2)
          Computes the in-place bitwise ANDNOT of this container with another (difference).
 Container iandNot(BitmapContainer B2)
          Computes the in-place bitwise ANDNOT of this container with another (difference).
 Container inot(int firstOfRange, int lastOfRange)
          Computes the in-place bitwise NOT of this container (complement).
 BitmapContainer ior(ArrayContainer value2)
          Computes the in-place bitwise OR of this container with another (union).
 Container ior(BitmapContainer B2)
          Computes the in-place bitwise OR of this container with another (union).
 Iterator<Short> iterator()
           
 Container ixor(ArrayContainer value2)
          Computes the in-place bitwise OR of this container with another (union).
 Container ixor(BitmapContainer B2)
          Computes the in-place bitwise OR of this container with another (union).
protected  void loadData(ArrayContainer arrayContainer)
           
 int nextSetBit(int i)
          Find the index of the next set bit greater or equal to i, returns -1 if none found.
 short nextUnsetBit(int i)
          Find the index of the next unset bit greater or equal to i, returns -1 if none found.
 Container not(int firstOfRange, int lastOfRange)
          Computes the bitwise NOT of this container (complement).
 BitmapContainer or(ArrayContainer value2)
          Computes the bitwise OR of this container with another (union).
 Container or(BitmapContainer value2)
          Computes the bitwise OR of this container with another (union).
 void readExternal(ObjectInput in)
           
 Container remove(short i)
          Remove the short from this container.
 ArrayContainer toArrayContainer()
          Copies the data to an array container
 String toString()
           
 void trim()
          If possible, recover wasted memory.
protected  void writeArray(DataOutput out)
          Write just the underlying array.
 void writeExternal(ObjectOutput out)
           
 Container xor(ArrayContainer value2)
          Computes the bitwise OR of this container with another (union).
 Container xor(BitmapContainer value2)
          Computes the bitwise OR of this container with another (union).
 
Methods inherited from class org.roaringbitmap.buffer.Container
and, andNot, iand, iandNot, ior, ixor, or, rangeOfOnes, xor
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

maxcapacity

protected static int maxcapacity
Constructor Detail

BitmapContainer

public BitmapContainer()
Create a bitmap container with all bits set to false


BitmapContainer

public BitmapContainer(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 index
lastOfRun - last index (range is inclusive)

BitmapContainer

public BitmapContainer(LongBuffer array,
                       int cardinality)
Construct a new BitmapContainer backed by the provided LongBuffer.

Parameters:
array - LongBuffer where the data is stored
cardinality - cardinality (number of values stored)
Method Detail

add

public Container add(short i)
Description copied from class: Container
Add a short to the container. May generate a new container.

Specified by:
add in class Container
Parameters:
i - short to be added
Returns:
the new container

and

public ArrayContainer and(ArrayContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

and

public Container and(BitmapContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

andNot

public Container andNot(ArrayContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

andNot

public Container andNot(BitmapContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

clear

public void clear()
Description copied from class: Container
Empties the container

Specified by:
clear in class Container

clone

public BitmapContainer clone()
Specified by:
clone in class Container

contains

public boolean contains(short i)
Description copied from class: Container
Checks whether the contain contains the provided value

Specified by:
contains in class Container
Parameters:
i - value to check
Returns:
whether the value is in the container

equals

public boolean equals(Object o)
Overrides:
equals in class Object

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: Container
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 class Container
Parameters:
x - provided array
i - starting index
mask - indicates most significant bits

getArraySizeInBytes

protected int getArraySizeInBytes()
Description copied from class: Container
Size of the underlying array

Specified by:
getArraySizeInBytes in class Container
Returns:
size in bytes

getCardinality

public int getCardinality()
Description copied from class: Container
Computes the distinct number of short values in the container. Can be expected to run in constant time.

Specified by:
getCardinality in class Container
Returns:
the cardinality

getShortIterator

public ShortIterator getShortIterator()
Description copied from class: Container
Iterator to visit the short values in the container

Specified by:
getShortIterator in class Container
Returns:
iterator

getSizeInBytes

public int getSizeInBytes()
Description copied from class: Container
Computes an estimate of the memory usage of this container. The estimate is not meant to be exact.

Specified by:
getSizeInBytes in class Container
Returns:
estimated memory usage in bytes

hashCode

public int hashCode()
Overrides:
hashCode in class Object

iand

public Container iand(ArrayContainer B2)
Description copied from class: Container
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 class Container
Parameters:
B2 - other container
Returns:
aggregated container

iand

public Container iand(BitmapContainer B2)
Description copied from class: Container
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 class Container
Parameters:
B2 - other container
Returns:
aggregated container

iandNot

public Container iandNot(ArrayContainer B2)
Description copied from class: Container
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 class Container
Parameters:
B2 - other container
Returns:
aggregated container

iandNot

public Container iandNot(BitmapContainer B2)
Description copied from class: Container
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 class Container
Parameters:
B2 - other container
Returns:
aggregated container

inot

public Container inot(int firstOfRange,
                      int lastOfRange)
Description copied from class: Container
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 class Container
Parameters:
firstOfRange - beginning of range (inclusive); 0 is beginning of this container.
lastOfRange - ending of range (exclusive)
Returns:
(partially) completmented container

ior

public BitmapContainer ior(ArrayContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

ior

public Container ior(BitmapContainer B2)
Description copied from class: Container
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 class Container
Parameters:
B2 - other container
Returns:
aggregated container

iterator

public Iterator<Short> iterator()
Specified by:
iterator in interface Iterable<Short>

ixor

public Container ixor(ArrayContainer value2)
Description copied from class: Container
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:
ixor in class Container
Parameters:
value2 - other container
Returns:
aggregated container

ixor

public Container ixor(BitmapContainer B2)
Description copied from class: Container
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:
ixor in class Container
Parameters:
B2 - other container
Returns:
aggregated container

loadData

protected void loadData(ArrayContainer 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

nextUnsetBit

public short nextUnsetBit(int i)
Find the index of the next unset bit greater or equal to i, returns -1 if none found.

Parameters:
i - starting index
Returns:
index of the next unset bit

not

public Container not(int firstOfRange,
                     int lastOfRange)
Description copied from class: Container
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 class Container
Parameters:
firstOfRange - beginning of range (inclusive); 0 is beginning of this container.
lastOfRange - ending of range (exclusive)
Returns:
(partially) completmented container

or

public BitmapContainer or(ArrayContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

or

public Container or(BitmapContainer value2)
Description copied from class: Container
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 class Container
Parameters:
value2 - other container
Returns:
aggregated container

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

remove

public Container remove(short i)
Description copied from class: Container
Remove the short from this container. May create a new container.

Specified by:
remove in class Container
Parameters:
i - to be removed
Returns:
New container

toArrayContainer

public ArrayContainer toArrayContainer()
Copies the data to an array container

Returns:
the array container

toString

public String toString()
Overrides:
toString in class Object

trim

public void trim()
Description copied from class: Container
If possible, recover wasted memory.

Specified by:
trim in class Container

writeArray

protected void writeArray(DataOutput out)
                   throws IOException
Description copied from class: Container
Write just the underlying array.

Specified by:
writeArray in class Container
Parameters:
out - output stream
Throws:
IOException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

xor

public Container xor(ArrayContainer value2)
Description copied from class: Container
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.

Specified by:
xor in class Container
Parameters:
value2 - other container
Returns:
aggregated container

xor

public Container xor(BitmapContainer value2)
Description copied from class: Container
Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.

Specified by:
xor in class Container
Parameters:
value2 - other container
Returns:
aggregated container


Copyright © 2014. All Rights Reserved.