|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsparsebitmap.SparseBitmap
public class SparseBitmap
The purpose of this class is to provide a compressed alternative to the Java BitSet class that can scale to much larger bit ranges. It also offers good processing performance while remaining simple.
| Field Summary | |
|---|---|
int[] |
buffer
buffer is where the data is store. |
int |
cardinality
Number of bits set to true. |
static int |
MINSTORAGEUSAGE
MINSTORAGEUSAGE determines how big the initial array is, by default. |
int |
sizeinwords
sizeinwords*32 is the the number of bits represented by this bitmap. |
static int |
WORDSIZE
We have a 32-bit implementation (ints are 32-bit in Java). |
int |
wordusage
How many words in buffer do we actually use? |
| Constructor Summary | |
|---|---|
SparseBitmap()
Constructs a SparseBitmap object with default parameters. |
|
SparseBitmap(int expectedstoragesize)
Constructs a SparseBitmap object. |
|
| Method Summary | |
|---|---|
void |
add(int wo,
int off)
For expert use: add a literal bitmap word so that the resulting bitmap will cover off+1 words. |
static SparseBitmap |
and(SparseBitmap... bitmaps)
Computes the bit-wise and aggregate over several bitmaps. |
SparseBitmap |
and(SparseBitmap o)
Compute the bit-wise logical and with another bitmap. |
static void |
and2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
Computes the bit-wise logical exclusive and of two bitmaps. |
static SparseBitmap |
bitmapOf(int... k)
Convenience method: will construct a bitmap with the specified bit sets. |
int |
compact()
Minimizes the memory usage by copying over the data on a smaller array. |
boolean |
equals(Object o)
Checks whether two SparseBitmap have the same bit sets. |
IntIterator |
getIntIterator()
Build a fast iterator over the set bits |
int |
hashCode()
Return a hash value for this object. |
Iterator<Integer> |
iterator()
Allow you to iterate over the set bits |
static SparseBitmap |
or(SparseBitmap... bitmaps)
Computes the bit-wise or aggregate over several bitmaps. |
SparseBitmap |
or(SparseBitmap o)
Computes the bit-wise logical or with another bitmap. |
static void |
or2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
Computes the bit-wise logical or of two bitmaps. |
void |
set(int i)
Set the bit at position i to true. |
int |
sizeInBytes()
Return how much space is used by data (in bytes). |
int[] |
toArray()
Convenience method: returns an array containing the set bits. |
static SparseBitmap |
xor(SparseBitmap... bitmaps)
Computes the bit-wise exclusive or aggregate over several bitmaps. |
SparseBitmap |
xor(SparseBitmap o)
Computes the bit-wise logical exclusive or with another bitmap. |
static void |
xor2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
Computes the bit-wise logical exclusive or of two bitmaps. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public int sizeinwords
public int cardinality
public static final int MINSTORAGEUSAGE
public int[] buffer
public int wordusage
public static final int WORDSIZE
| Constructor Detail |
|---|
public SparseBitmap()
public SparseBitmap(int expectedstoragesize)
expectedstoragesize - this parameter corresponds to the initial memory allocation| Method Detail |
|---|
public void add(int wo,
int off)
add in interface BitmapContainerwo - literal bitmap word to addoff - position at (total size will be off+1)public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic int[] toArray()
public static SparseBitmap bitmapOf(int... k)
k - the list of bits to set
public void set(int i)
i - public Iterator<Integer> iterator()
iterator in interface Iterable<Integer>public IntIterator getIntIterator()
public SparseBitmap and(SparseBitmap o)
o - another bitmap
public static void and2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
container - where the data will be storedbitmap1 - the first bitmapbitmap2 - the second bitmappublic SparseBitmap or(SparseBitmap o)
o - another bitmap
public static void or2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
container - where the data will be storedbitmap1 - the first bitmapbitmap2 - the second bitmappublic SparseBitmap xor(SparseBitmap o)
o - another bitmap
public static void xor2by2(BitmapContainer container,
SparseBitmap bitmap1,
SparseBitmap bitmap2)
container - where the data will be storedbitmap1 - the first bitmapbitmap2 - the second bitmappublic static SparseBitmap and(SparseBitmap... bitmaps)
bitmaps - the bitmaps to aggregate
public static SparseBitmap or(SparseBitmap... bitmaps)
bitmaps - the bitmaps to aggregate
public static SparseBitmap xor(SparseBitmap... bitmaps)
bitmaps - the bitmaps to aggregate
public int sizeInBytes()
sizeInBytes in interface BitmapContainerpublic int compact()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||