Package fj.data.hamt
Class BitSet
- java.lang.Object
-
- fj.data.hamt.BitSet
-
public final class BitSet extends java.lang.ObjectA 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 longBASE_LONGstatic BitSetEMPTYstatic intFALSE_BITstatic intMAX_BIT_INDEXstatic intMAX_BIT_SIZEstatic intTRUE_BITprivate longvalue
-
Constructor Summary
Constructors Modifier Constructor Description privateBitSet(long l)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BitSetand(BitSet bs)java.lang.StringasString()intbitsOn()intbitsToRight(int index)intbitsUsed()BitSetclear(int index)static BitSetempty()booleanequals(java.lang.Object obj)<A> AfoldLeft(F2<A,java.lang.Boolean,A> f, A acc)<A> AfoldRight(F2<java.lang.Boolean,A,A> f, A acc)booleanisEmpty()booleanisSet(int index)static BitSetlistBitSet(List<java.lang.Boolean> list)static BitSetlongBitSet(long l)longlongValue()BitSetnot()BitSetor(BitSet bs)BitSetrange(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.BitSetset(int index)BitSetset(int index, boolean b)BitSetshiftLeft(int n)BitSetshiftRight(int n)static BitSetstreamBitSet(Stream<java.lang.Boolean> s)static BitSetstringBitSet(java.lang.String s)BitSettakeLower(int n)BitSettakeUpper(int n)static booleantoBoolean(char c)static booleantoBoolean(int i)static inttoInt(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.StringtoString()BitSetxor(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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin 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()
-
-