Package fj.data.hamt
Class BitSet
java.lang.Object
fj.data.hamt.BitSet
A sequence of bits representing a value. The most significant bit (the
bit with the highest value) is the leftmost bit and has the highest index.
For example, the BitSet("1011") represents the decimal number 11 and has
indices [3, 0] inclusive where the bit with the lowest value has the lowest
index and is the rightmost bit.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final BitSet
static final int
static final int
static final int
static final int
private final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()
int
bitsOn()
int
bitsToRight
(int index) int
bitsUsed()
clear
(int index) static BitSet
empty()
boolean
<A> A
<A> A
boolean
isEmpty()
boolean
isSet
(int index) static BitSet
listBitSet
(List<Boolean> list) static BitSet
longBitSet
(long l) long
not()
range
(int highIndex, int lowIndex) Returns the bit set from indices in the range from low (inclusive) to high(exclusive) from the least significant bit (on the right), e.g.set
(int index) set
(int index, boolean b) shiftLeft
(int n) shiftRight
(int n) static BitSet
static BitSet
takeLower
(int n) takeUpper
(int n) static boolean
toBoolean
(char c) static boolean
toBoolean
(int i) static int
toInt
(boolean b) toList()
toStream()
Returns a stream of boolean where the head is the most significant bit (the bit with the largest value)toString()
-
Field Details
-
TRUE_BIT
public static final int TRUE_BIT- See Also:
-
FALSE_BIT
public static final int FALSE_BIT- See Also:
-
EMPTY
-
BASE_LONG
public static final long BASE_LONG- See Also:
-
MAX_BIT_SIZE
public static final int MAX_BIT_SIZE- See Also:
-
MAX_BIT_INDEX
public static final int MAX_BIT_INDEX- See Also:
-
value
private final long value
-
-
Constructor Details
-
BitSet
private BitSet(long l)
-
-
Method Details
-
empty
-
longBitSet
-
listBitSet
-
streamBitSet
-
stringBitSet
-
isSet
public boolean isSet(int index) -
isEmpty
public boolean isEmpty() -
set
-
set
-
clear
-
longValue
public long longValue() -
and
-
or
-
shiftRight
-
shiftLeft
-
bitsUsed
public int bitsUsed() -
bitsOn
public int bitsOn() -
toStream
Returns a stream of boolean where the head is the most significant bit (the bit with the largest value) -
toString
-
equals
-
bitsToRight
public int bitsToRight(int index) -
toList
-
foldRight
-
foldLeft
-
xor
-
not
-
takeLower
-
takeUpper
-
range
Returns the bit set from indices in the range from low (inclusive) to high(exclusive) from the least significant bit (on the right), e.g. "101101".range(1, 4) == "0110" -
toBoolean
public static boolean toBoolean(char c) -
toBoolean
public static boolean toBoolean(int i) -
toInt
public static int toInt(boolean b) -
asString
-