public class BitList
extends java.lang.Object
when converting to and from bytes and larger numbers, this representation uses the least-significant first convention both for bits and for bytes (little endian)
(i.e. least significant byte is first, as is the least significant bit; ninth element in this list is the least significant bit in the second byte, so a list {0,0,0,0,0,0,0,0,1,0} represents 256)
Modifier and Type | Method and Description |
---|---|
BitList |
anded(BitList other)
represents the result of this bit list logically ANDed with the other
|
boolean[] |
asArray() |
java.math.BigInteger |
asBigInteger() |
java.util.BitSet |
asBitSet()
nb: BitSet forgets the length
|
java.util.List<java.lang.Byte> |
asByteList() |
byte[] |
asBytes()
returns the bits converted to bytes, with least significant bit first
*and* first 8 bits in the first byte
|
java.util.List<java.lang.Boolean> |
asList() |
int[] |
asUnsignedBytes() |
byte |
byteValue()
returns value of this as a byte(ignoring any too-high bits)
|
int |
commonPrefixLength(BitList other) |
boolean |
equals(java.lang.Object obj) |
boolean |
get(int index) |
int |
hashCode() |
int |
intValue()
returns value of this as an integer (ignoring any too-high bits)
|
boolean |
isEmpty()
true iff the length is 0; see also isZero
|
boolean |
isZero()
true iff all bits are 0
|
int |
length() |
long |
longValue()
returns value of this as a long (ignoring any too-high bits)
|
static BitList |
newInstance(java.math.BigInteger x) |
static BitList |
newInstance(java.util.BitSet bits,
int length) |
static BitList |
newInstance(boolean... l) |
static BitList |
newInstance(byte... bytes) |
static BitList |
newInstance(java.util.List<java.lang.Boolean> l) |
static BitList |
newInstanceFromBytes(int... bytes)
as
newInstance(byte...) , but accepting ints for convenience;
only the least significant 8 bits of the parameters are considered |
BitList |
notted()
represents the result of this bit list logically notted
|
BitList |
orred(BitList other)
represents the result of this bit list logically ORred with the other
|
BitList |
resized(int length)
creates a new instance with the given length, either reducing the list or padding it with 0's
(at the end, in both cases)
|
BitList |
reversed() |
java.lang.String |
toString() |
BitList |
xorred(BitList other)
represents the result of this bit list logically XORred with the other
|
public static BitList newInstance(java.util.BitSet bits, int length)
public int length()
public boolean get(int index)
public static BitList newInstance(byte... bytes)
public static BitList newInstanceFromBytes(int... bytes)
newInstance(byte...)
, but accepting ints for convenience;
only the least significant 8 bits of the parameters are consideredpublic static BitList newInstance(java.util.List<java.lang.Boolean> l)
public static BitList newInstance(boolean... l)
public static BitList newInstance(java.math.BigInteger x)
public byte[] asBytes()
NB this may be different to BitSet.valueOf available since java 7 (as late as that!) which reverses the order of the bytes
public int[] asUnsignedBytes()
public java.util.BitSet asBitSet()
public java.util.List<java.lang.Boolean> asList()
public BitList orred(BitList other)
public BitList anded(BitList other)
public BitList xorred(BitList other)
public BitList notted()
public BitList resized(int length)
public BitList reversed()
public int commonPrefixLength(BitList other)
public boolean isEmpty()
public boolean isZero()
public java.math.BigInteger asBigInteger()
public boolean[] asArray()
public java.util.List<java.lang.Byte> asByteList()
public byte byteValue()
public int intValue()
public long longValue()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object