Package fj.data.hamt
Class BitSet
- java.lang.Object
-
- fj.data.hamt.BitSet
-
public final class BitSet extends java.lang.Object
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
Fields Modifier and Type Field Description static long
BASE_LONG
static BitSet
EMPTY
static int
FALSE_BIT
static int
MAX_BIT_INDEX
static int
MAX_BIT_SIZE
static int
TRUE_BIT
private long
value
-
Constructor Summary
Constructors Modifier Constructor Description private
BitSet(long l)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BitSet
and(BitSet bs)
java.lang.String
asString()
int
bitsOn()
int
bitsToRight(int index)
int
bitsUsed()
BitSet
clear(int index)
static BitSet
empty()
boolean
equals(java.lang.Object obj)
<A> A
foldLeft(F2<A,java.lang.Boolean,A> f, A acc)
<A> A
foldRight(F2<java.lang.Boolean,A,A> f, A acc)
boolean
isEmpty()
boolean
isSet(int index)
static BitSet
listBitSet(List<java.lang.Boolean> list)
static BitSet
longBitSet(long l)
long
longValue()
BitSet
not()
BitSet
or(BitSet bs)
BitSet
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.BitSet
set(int index)
BitSet
set(int index, boolean b)
BitSet
shiftLeft(int n)
BitSet
shiftRight(int n)
static BitSet
streamBitSet(Stream<java.lang.Boolean> s)
static BitSet
stringBitSet(java.lang.String s)
BitSet
takeLower(int n)
BitSet
takeUpper(int n)
static boolean
toBoolean(char c)
static boolean
toBoolean(int i)
static int
toInt(boolean b)
List<java.lang.Boolean>
toList()
Stream<java.lang.Boolean>
toStream()
Returns a stream of boolean where the head is the most significant bit (the bit with the largest value)java.lang.String
toString()
BitSet
xor(BitSet bs)
-
-
-
Field Detail
-
TRUE_BIT
public static final int TRUE_BIT
- See Also:
- Constant Field Values
-
FALSE_BIT
public static final int FALSE_BIT
- See Also:
- Constant Field Values
-
EMPTY
public static final BitSet EMPTY
-
BASE_LONG
public static final long BASE_LONG
- See Also:
- Constant Field Values
-
MAX_BIT_SIZE
public static final int MAX_BIT_SIZE
- See Also:
- Constant Field Values
-
MAX_BIT_INDEX
public static final int MAX_BIT_INDEX
- See Also:
- Constant Field Values
-
value
private final long value
-
-
Method Detail
-
empty
public static BitSet empty()
-
longBitSet
public static BitSet longBitSet(long l)
-
stringBitSet
public static BitSet stringBitSet(java.lang.String s)
-
isSet
public boolean isSet(int index)
-
isEmpty
public boolean isEmpty()
-
set
public BitSet set(int index)
-
set
public BitSet set(int index, boolean b)
-
clear
public BitSet clear(int index)
-
longValue
public long longValue()
-
shiftRight
public BitSet shiftRight(int n)
-
shiftLeft
public BitSet shiftLeft(int n)
-
bitsUsed
public int bitsUsed()
-
bitsOn
public int bitsOn()
-
toStream
public Stream<java.lang.Boolean> toStream()
Returns a stream of boolean where the head is the most significant bit (the bit with the largest value)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
bitsToRight
public int bitsToRight(int index)
-
toList
public List<java.lang.Boolean> toList()
-
foldRight
public <A> A foldRight(F2<java.lang.Boolean,A,A> f, A acc)
-
foldLeft
public <A> A foldLeft(F2<A,java.lang.Boolean,A> f, A acc)
-
not
public BitSet not()
-
takeLower
public BitSet takeLower(int n)
-
takeUpper
public BitSet takeUpper(int n)
-
range
public BitSet 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. "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
public java.lang.String asString()
-
-