Package com.pnfsoftware.jeb.util.collect
Class Bitmap
java.lang.Object
com.pnfsoftware.jeb.util.collect.Bitmap
A fast, efficient bitmap making optimal use of memory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllFrom
(Bitmap other) Add the values of a source bitmap into this bitmap.void
clear()
Clear the bitmap to all false.clone()
int
Count the number of true values in the bitmap.int
Count the number of false values in the bitmap.boolean
formatAsRanges
(boolean useExcludedEnds) boolean
get
(int i) Retrieve the value of a bit.int
hashCode()
boolean
isEmpty()
Determine whether all entries in the bitmap are set to false.boolean
isFull()
Determine whether all entries in the bitmap are set to true.ones()
Generate a list of zero-based indices for the bitmap entry is true.void
removeAllFrom
(Bitmap other) Remove the values of a source bitmap into this bitmap.void
reset
(int i) Fast reset a bit to false.void
set
(int i) Fast set a bit to true.boolean
set
(int i, boolean v) Set a bit to the provided value.void
setRange
(int from, int to) Fast set multiple bits to true.int
size()
Retrieve the map size.toString()
-
Constructor Details
-
Bitmap
public Bitmap(int bitsize)
-
-
Method Details
-
clone
-
hashCode
public int hashCode() -
equals
-
size
public int size()Retrieve the map size.- Returns:
-
countOnes
public int countOnes()Count the number of true values in the bitmap.- Returns:
-
countZeros
public int countZeros()Count the number of false values in the bitmap.- Returns:
-
clear
public void clear()Clear the bitmap to all false. -
set
public boolean set(int i, boolean v) Set a bit to the provided value.- Parameters:
i
- zero-based indexv
- value- Returns:
- true if the value was updated; false if it was unchanged
-
set
public void set(int i) Fast set a bit to true.- Parameters:
i
- zero-based index
-
setRange
public void setRange(int from, int to) Fast set multiple bits to true.- Parameters:
from
- start zero-based index (inclusive)to
- end zero-based index (exclusive)
-
reset
public void reset(int i) Fast reset a bit to false.- Parameters:
i
- zero-based index
-
get
public boolean get(int i) Retrieve the value of a bit.- Parameters:
i
- zero-based index- Returns:
- the current bit value
-
addAllFrom
Add the values of a source bitmap into this bitmap. Both bitmaps must have the same size.- Parameters:
other
- source bitmap
-
removeAllFrom
Remove the values of a source bitmap into this bitmap. Both bitmaps must have the same size.- Parameters:
other
- source bitmap
-
isFull
public boolean isFull()Determine whether all entries in the bitmap are set to true.- Returns:
-
isEmpty
public boolean isEmpty()Determine whether all entries in the bitmap are set to false.- Returns:
-
ones
Generate a list of zero-based indices for the bitmap entry is true.- Returns:
- a list of integers
-
toString
-
formatAsRanges
-
formatAsRanges
-