Produce a single flat Bytes
by interpreting
any non-byte-aligned appends or drops.
Produce a single flat Bytes
by interpreting
any non-byte-aligned appends or drops. Unlike
compact
, the underlying ByteVector
is not
necessarily copied.
Returns a vector of all bits in this vector except the first n
bits.
Returns a vector of all bits in this vector except the first n
bits.
The resulting vector's size is 0 max (size - n)
.
Returns true if the n
th bit is high, false otherwise.
Returns true if the n
th bit is high, false otherwise.
NoSuchElementException
if n >= size
Returns the n
th byte, 0-indexed.
Returns the n
th byte, 0-indexed.
NoSuchElementException
if n >= bytes.size
Returns number of bits in this vector.
Returns true
if the size of this BitVector
is less than n
.
Returns true
if the size of this BitVector
is less than n
. Unlike size
, this
forces this BitVector
from left to right, halting as soon as it has a definite answer.
Returns a vector of the first n
bits of this vector.
Returns a vector of the first n
bits of this vector.
The resulting vector's size is n min size
.
Note: if an n
-bit vector is required, use the acquire
method instead.
acquire
Returns a new bit vector with the n
th bit high if high
is true or low if high
is false.
Returns a bitwise AND of this value with the specified value.
Returns a bitwise AND of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Returns a new bit vector representing this vector's contents followed by the specified vector's contents.
Returns a new vector with the specified bit prepended.
Returns a new vector with the specified bit appended.
Returns a value of the same size with each bit shifted to the left n
bits.
Returns a value of the same size with each bit shifted to the left n
bits.
Returns true if the specified BitVector
has the same contents as this vector.
Returns a value of the same size with each bit shifted to the right n
bits where the n
left-most bits are sign extended.
Returns a value of the same size with each bit shifted to the right n
bits where the n
left-most bits are sign extended.
Returns a value of the same size with each bit shifted to the right n
bits where the n
left-most bits are low.
Returns a value of the same size with each bit shifted to the right n
bits where the n
left-most bits are low.
Returns a bitwise XOR of this value with the specified value.
Returns a bitwise XOR of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Returns a vector whose contents are the results of taking the first n
bits of this vector.
Returns a vector whose contents are the results of taking the first n
bits of this vector.
If this vector does not contain at least n
bits, an error message is returned.
take
Like aquire
, but immediately consumes the Either
via the pair of functions err
and f
.
Like aquire
, but immediately consumes the Either
via the pair of functions err
and f
.
acquire
Returns a bitwise AND of this bit vector with the specified bit vector.
Returns a bitwise AND of this bit vector with the specified bit vector.
The resulting bit vector's size is the minimum of this bit vector's size and the specified bit vector's size.
Alias for get
.
Alias for get
.
get(Long)
Alias for toByteVector.
Returns a new bit vector with the n
th bit low (and all other bits unmodified).
Return a BitVector
with the same contents as this
, but
based off a single ByteVector
.
Return a BitVector
with the same contents as this
, but
based off a single ByteVector
.
This may involve copying data to a fresh ByteVector
, but
has the advantage that lookups index directly into a single
ByteVector
rather than traversing a logarithmic number of nodes
in this tree.
Calling this method on an already compacted vector is a no-op.
Consumes the first n
bits of this vector and decodes them with the specified function,
resulting in a vector of the remaining bits and the decoded value.
Consumes the first n
bits of this vector and decodes them with the specified function,
resulting in a vector of the remaining bits and the decoded value. If this vector
does not have n
bits or an error occurs while decoding, an error is returned instead.
If this vector has at least n
bits, returns f(take(n),drop(n))
,
otherwise calls err
with a meaningful error message.
If this vector has at least n
bits, returns f(take(n),drop(n))
,
otherwise calls err
with a meaningful error message. This function can be used
to avoid intermediate allocations of Either
objects when using acquire
or consume
directly.
acquireThen
Determines if the specified slice is in this vector.
Return a BitVector
with the same contents as this
, but
based off a single flat ByteVector
.
Return a BitVector
with the same contents as this
, but
based off a single flat ByteVector
. This function is guaranteed
to copy all the bytes in this BitVector
, unlike compact
, which
may no-op if this BitVector
already consists of a single ByteVector
chunk.
Decodes this vector as a string using the US-ASCII charset.
Decodes this vector as a string using the implicitly available charset.
Decodes this vector as a string using the UTF-8 charset.
Decrypts this bit vector using the specified cipher and key.
Decrypts this bit vector using the specified cipher and key.
The last byte is zero padded if the size is not evenly divisible by 8.
cipher to use for decryption
key to decrypt with
optional algorithm paramaters used for decryption (e.g., initialization vector)
secure random
Compresses this vector using ZLIB.
Compresses this vector using ZLIB.
The last byte is zero padded if the size is not evenly divisible by 8.
compression level, 0-9, with 0 disabling compression and 9 being highest level of compression -- see java.util.zip.Deflater
for details
compression strategy -- see java.util.zip.Deflater
for details
if true, ZLIB header and checksum will not be used
buffer size, in bytes, to use when compressing
Computes a digest of this bit vector.
Computes a digest of this bit vector.
Exceptions thrown from the underlying JCA API are propagated.
The last byte is zero padded if the size is not evenly divisible by 8.
digest to use
Computes a digest of this bit vector.
Computes a digest of this bit vector.
Exceptions thrown from the underlying JCA API are propagated.
The last byte is zero padded if the size is not evenly divisible by 8.
digest algorithm to use
Returns a vector of all bits in this vector except the last n
bits.
Returns a vector of all bits in this vector except the last n
bits.
The resulting vector's size is 0 max (size - n)
.
Encrypts this bit vector using the specified cipher and key.
Encrypts this bit vector using the specified cipher and key.
The last byte is zero padded if the size is not evenly divisible by 8.
cipher to use for encryption
key to encrypt with
optional algorithm paramaters used for encryption (e.g., initialization vector)
secure random
Returns true if this bit vector ends with the specified vector.
Returns true if the specified value is a BitVector
with the same contents as this vector.
Returns true if the specified value is a BitVector
with the same contents as this vector.
Forces any Suspend
nodes in this BitVector
and ensures the tree is balanced.
Converts this vector in to a sequence of n
-bit vectors.
Calculates the hash code of this vector.
Calculates the hash code of this vector. The result is cached.
Returns the first bit of this vector or throws if vector is emtpy.
Returns the first bit of this vector or None
if vector is emtpy.
Returns a bitwise if-and-only-if of this value with the specified value.
Returns a bitwise if-and-only-if of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Returns a bitwise implication of this value with the specified value.
Returns a bitwise implication of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Finds the first index after from
of the specified bit pattern in this vector.
Finds the first index after from
of the specified bit pattern in this vector.
index of slice or -1 if not found
Finds the first index of the specified bit pattern in this vector.
Finds the first index of the specified bit pattern in this vector.
index of slice or -1 if not found
Decompresses this vector using ZLIB.
Decompresses this vector using ZLIB.
The last byte is zero padded if the size is not evenly divisible by 8.
buffer size, in bytes, to use when compressing
Returns a vector of all bits in this vector except the last bit.
Returns a vector with the specified bit inserted at the specified index.
Returns the number of bits in this vector, or None
if the size does not
fit into an Int
.
Inverse of reverseByteOrder
.
Returns true if this vector has no bits.
Returns the last bit in this vector or throws if vector is empty.
Returns the last bit in this vector or returns None
if vector is empty.
Alias for size.
Returns Some(true)
if the n
th bit is high, Some(false)
if low, and None
if n >= size
.
Returns a bitwise NAND of this value with the specified value.
Returns a bitwise NAND of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Returns true if this vector has a non-zero number of bits.
Returns a bitwise NOR of this value with the specified value.
Returns a bitwise NOR of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Returns a bitwise complement of this bit vector.
Returns a bitwise complement of this bit vector.
Returns a bitwise OR of this bit vector with the specified bit vector.
Returns a bitwise OR of this bit vector with the specified bit vector.
The resulting bit vector's size is the minimum of this bit vector's size and the specified bit vector's size.
Returns an n
-bit vector whose contents are 0 or more low bits followed by this vector's contents.
Returns an n
-bit vector whose contents are 0 or more low bits followed by this vector's contents.
IllegalArgumentException
if n < size
Returns an n
-bit vector whose contents are 0 or more low bits followed by this vector's contents.
Returns an n
-bit vector whose contents are 0 or more low bits followed by this vector's contents.
IllegalArgumentException
if n < size
Alias for padRight
.
Alias for padRight
.
IllegalArgumentException
if n < size
Returns a vector with the specified bit vector replacing bits [idx, idx + b.size]
.
Returns the number of bits that are high.
Reverse the bits of this vector.
Returns a new vector of the same size with the bit order reversed.
Returns a new vector of the same size with the byte order reversed.
Returns a new vector of the same size with the byte order reversed.
Note that reverseByteOrder.reverseByteOrder == identity
only when size
is evenly divisble by 8.
To invert reverseByteOrder
for an arbitrary size, use invertReverseByteOrder
.
Returns a bit vector of the same size with each bit circularly shifted to the left n
bits.
Returns a bit vector of the same size with each bit circularly shifted to the left n
bits.
Returns a bit vector of the same size with each bit circularly shifted to the right n
bits.
Returns a bit vector of the same size with each bit circularly shifted to the right n
bits.
Returns a new bit vector with the n
th bit high (and all other bits unmodified).
Returns a bit vector of the same size with each bit shifted to the left n
bits.
Returns a bit vector of the same size with each bit shifted to the left n
bits.
Returns a bit vector of the same size with each bit shifted to the right n
bits.
Returns a bit vector of the same size with each bit shifted to the right n
bits.
whether the n
left-msot bits should take on the value of bit 0
Returns true
if the size of this BitVector
is greater than n
.
Returns true
if the size of this BitVector
is greater than n
. Unlike size
, this
forces this BitVector
from left to right, halting as soon as it has a definite answer.
Returns true
if the size of this BitVector
is greater than or equal to n
.
Returns true
if the size of this BitVector
is greater than or equal to n
. Unlike size
, this
forces this BitVector
from left to right, halting as soon as it has a definite answer.
Returns true
if the size of this BitVector
is less than or equal to n
.
Returns true
if the size of this BitVector
is less than or equal to n
. Unlike size
, this
forces this BitVector
from left to right, halting as soon as it has a definite answer.
Returns a vector made up of the bits starting at index from
up to index until
,
not including the index until
.
Convert a slice of bits from this vector (start
until start+bits
) to a Byte
.
Convert a slice of bits from this vector (start
until start+bits
) to a Byte
.
whether sign extension should be performed
IllegalArgumentException
if the slice refers to indices that are out of range
Convert a slice of bits from this vector (start
until start+bits
) to an Int
.
Convert a slice of bits from this vector (start
until start+bits
) to an Int
.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if the slice refers to indices that are out of range
Convert a slice of bits from this vector (start
until start+bits
) to a Long
.
Convert a slice of bits from this vector (start
until start+bits
) to a Long
.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if the slice refers to indices that are out of range
Convert a slice of bits from this vector (start
until start+bits
) to a Short
.
Convert a slice of bits from this vector (start
until start+bits
) to a Short
.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if the slice refers to indices that are out of range
Returns a vector with the specified bit vector inserted at the specified index.
Returns a pair of vectors that is equal to (take(n), drop(n))
.
Returns true if this bit vector starts with the specified vector.
Returns a vector of all bits in this vector except the first bit.
Returns a vector of the last n
bits of this vector.
Returns a vector of the last n
bits of this vector.
The resulting vector's size is n min size
.
Converts the contents of this vector to a base 64 string using the specified alphabet.
Converts the contents of this vector to a base 64 string using the specified alphabet.
The last byte is right-padded with zeros if the size is not evenly divisible by 8.
Converts the contents of this vector to a base 64 string.
Converts the contents of this vector to a base 64 string.
The last byte is right-padded with zeros if the size is not evenly divisible by 8.
Converts the contents of this bit vector to a binary string of size
digits.
Converts the contents of this bit vector to a binary string of size
digits.
Converts the contents of this vector to a byte.
Converts the contents of this vector to a byte.
whether sign extension should be performed
IllegalArgumentException
if size is greater than 8
Converts the contents of this vector to a byte array.
Converts the contents of this vector to a byte array.
If this vector's size does not divide evenly by 8, the last byte of the returned vector will be zero-padded to the right.
Converts the contents of this vector to a java.nio.ByteBuffer
.
Converts the contents of this vector to a java.nio.ByteBuffer
.
The returned buffer is freshly allocated with limit set to the minimum number of bytes needed to represent the contents of this vector, position set to zero, and remaining set to the limit.
toByteVector
Converts the contents of this vector to a byte vector.
Converts the contents of this vector to a byte vector.
If this vector's size does not divide evenly by 8, the last byte of the returned vector will be zero-padded to the right.
Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4)
nibbles.
Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4)
nibbles.
The last nibble is right-padded with zeros if the size is not evenly divisible by 4.
Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4)
nibbles.
Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4)
nibbles.
The last nibble is right-padded with zeros if the size is not evenly divisible by 4.
Return the sequence of bits in this vector.
Return the sequence of bits in this vector. The returned
IndexedSeq
is just a view; nothing is actually copied.
IllegalArgumentException
if this vector's size exceeds Int.MaxValue
toIndexedSeq
acquire
Converts the contents of this vector to an int.
Converts the contents of this vector to an int.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if size is greater than 32
Converts the contents of this vector to a long.
Converts the contents of this vector to a long.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if size is greater than 64
Converts the contents of this vector to a short.
Converts the contents of this vector to a short.
whether sign extension should be performed
order bytes should be processed in
IllegalArgumentException
if size is greater than 16
Display the size and bytes of this BitVector
.
Display the size and bytes of this BitVector
.
For bit vectors beyond a certain size, only a hash of the
contents are shown.
Converts the contents of this bit vector to a UUID.
Converts the contents of this bit vector to a UUID.
IllegalArgumentException
if size is not exactly 128.
Returns a bitwise complement of this value.
Returns a bitwise complement of this value.
Returns a bitwise XOR of this bit vector with the specified bit vector.
Returns a bitwise XOR of this bit vector with the specified bit vector.
The resulting bit vector's size is the minimum of this bit vector's size and the specified bit vector's size.
Returns a bitwise OR of this value with the specified value.
Returns a bitwise OR of this value with the specified value.
The resulting value's size is the minimum of this value's size and the specified value's size.
Persistent vector of bits, stored as bytes.
Bits are numbered left to right, starting at 0.