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 TypeMethodDescriptionvoidaddAllFrom(Bitmap other) Add the values of a source bitmap into this bitmap.voidclear()Clear the bitmap to all false.clone()intCount the number of true values in the bitmap.intCount the number of false values in the bitmap.booleanformatAsRanges(boolean useExcludedEnds) booleanget(int i) Retrieve the value of a bit.inthashCode()booleanisEmpty()Determine whether all entries in the bitmap are set to false.booleanisFull()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.voidremoveAllFrom(Bitmap other) Remove the values of a source bitmap into this bitmap.voidreset(int i) Fast reset a bit to false.voidset(int i) Fast set a bit to true.booleanset(int i, boolean v) Set a bit to the provided value.voidsetRange(int from, int to) Fast set multiple bits to true.intsize()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
-