Companion for BitVector.
Document{}
1-bit vector with only bit set to specified value.
1-bit vector with only bit set to specified value.
n-bit vector with bit at index i
set to value of boolean at index i
in specified iterable.
n-bit vector with bit at index i
set to value of boolean at index i
in specified iterable.
Constructs a BitVector
from a ByteVector
.
This method has runtime O(1).
Constructs a BitVector
from a ByteVector
.
This method has runtime O(1).
Constructs a BitVector
from a ByteBuffer
. The given ByteBuffer
is
is copied to ensure the resulting BitVector
is immutable.
If this is not desired, use BitVector.view
.
Constructs a BitVector
from a ByteBuffer
. The given ByteBuffer
is
is copied to ensure the resulting BitVector
is immutable.
If this is not desired, use BitVector.view
.
Constructs a BitVector
from an Array[Byte]
. The given Array[Byte]
is
is copied to ensure the resulting BitVector
is immutable.
If this is not desired, use BitVector.view
.
Constructs a BitVector
from an Array[Byte]
. The given Array[Byte]
is
is copied to ensure the resulting BitVector
is immutable.
If this is not desired, use BitVector.view
.
Constructs a BitVector
from a collection of bytes.
Constructs a BitVector
from a collection of bytes.
Constructs a BitVector
from a list of literal bytes. Only the least significant
byte is used of each integral value.
Constructs a BitVector
from a list of literal bytes. Only the least significant
byte is used of each integral value.
Constructs a BitVector
from a ByteBuffer
using the buffer limit * 8 as the size.
Unlike apply
, this does not make a copy of the input buffer, so callers should take care
not to modify the contents of the buffer passed to this function.
Constructs a BitVector
from a ByteBuffer
using the buffer limit * 8 as the size.
Unlike apply
, this does not make a copy of the input buffer, so callers should take care
not to modify the contents of the buffer passed to this function.
Constructs a BitVector
from the first sizeInBits
of the ByteBuffer
.
Unlike apply
, this does not make a copy of the input buffer, so callers should take care
not to modify the contents of the buffer passed to this function.
Constructs a BitVector
from the first sizeInBits
of the ByteBuffer
.
Unlike apply
, this does not make a copy of the input buffer, so callers should take care
not to modify the contents of the buffer passed to this function.
Constructs a BitVector
from an Array[Byte]
. Unlike apply
, this
does not make a copy of the input array, so callers should take care
not to modify the contents of the array passed to this function.
Constructs a BitVector
from an Array[Byte]
. Unlike apply
, this
does not make a copy of the input array, so callers should take care
not to modify the contents of the array passed to this function.
Constructs a BitVector
from an Array[Byte]
. Unlike apply
, this
does not make a copy of the input array, so callers should take care
not to modify the contents of the array passed to this function.
Constructs a BitVector
from an Array[Byte]
. Unlike apply
, this
does not make a copy of the input array, so callers should take care
not to modify the contents of the array passed to this function.
Constructs an n
-bit BitVector
where each bit is set to the specified value.
Constructs an n
-bit BitVector
where each bit is set to the specified value.
Constructs a bit vector with the 2's complement encoding of the specified byte.
Constructs a bit vector with the 2's complement encoding of the specified byte.
- Value Params
- b
value to encode
- size
size of vector (<= 8)
Constructs a bit vector with the 2's complement encoding of the specified value.
Constructs a bit vector with the 2's complement encoding of the specified value.
- Value Params
- ordering
byte ordering of vector
- s
value to encode
- size
size of vector (<= 16)
Constructs a bit vector with the 2's complement encoding of the specified value.
Constructs a bit vector with the 2's complement encoding of the specified value.
- Value Params
- i
value to encode
- ordering
byte ordering of vector
- size
size of vector (<= 32)
Constructs a bit vector with the 2's complement encoding of the specified value.
Constructs a bit vector with the 2's complement encoding of the specified value.
- Value Params
- l
value to encode
- ordering
byte ordering of vector
- size
size of vector (<= 64)
Constructs a bit vector containing the binary representation of the specified UUID. The bits are in MSB-to-LSB order.
Constructs a bit vector containing the binary representation of the specified UUID. The bits are in MSB-to-LSB order.
- Value Params
- u
value to encode
Constructs a BitVector
from a binary string or returns an error message if the string is not valid binary.
Constructs a BitVector
from a binary string or returns an error message if the string is not valid binary.
The string may start with a 0b
and it may contain whitespace or underscore characters.
Constructs a BitVector
from a binary string or returns None
if the string is not valid binary.
Constructs a BitVector
from a binary string or returns None
if the string is not valid binary.
The string may start with a 0b
and it may contain whitespace or underscore characters.
Constructs a BitVector
from a binary string or throws an IllegalArgumentException if the string is not valid binary.
Constructs a BitVector
from a binary string or throws an IllegalArgumentException if the string is not valid binary.
The string may start with a 0b
and it may contain whitespace or underscore characters.
- Throws
- IllegalArgumentException
if the string is not valid hexadecimal
Constructs a BitVector
from a hexadecimal string or returns an error message if the string is not valid hexadecimal.
Constructs a BitVector
from a hexadecimal string or returns an error message if the string is not valid hexadecimal.
The string may start with a 0x
and it may contain whitespace or underscore characters.
Constructs a BitVector
from a hexadecimal string or returns None
if the string is not valid hexadecimal.
Constructs a BitVector
from a hexadecimal string or returns None
if the string is not valid hexadecimal.
The string may start with a 0x
and it may contain whitespace or underscore characters.
Constructs a BitVector
from a hexadecimal string or throws an IllegalArgumentException if the string is not valid hexadecimal.
Constructs a BitVector
from a hexadecimal string or throws an IllegalArgumentException if the string is not valid hexadecimal.
The string may start with a 0x
and it may contain whitespace or underscore characters.
- Throws
- IllegalArgumentException
if the string is not valid hexadecimal
Constructs a BitVector
from a base 32 string or returns an error message if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 32 string or returns an error message if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 32 string or returns None
if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 32 string or returns None
if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 32 string or throws an IllegalArgumentException if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 32 string or throws an IllegalArgumentException if the string is not valid base 32.
Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive.
The string may contain whitespace characters which are ignored.
- Throws
- IllegalArgumentException
if the string is not valid base 32
Constructs a BitVector
from a base 58 string or returns an error message if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 58 string or returns an error message if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 58 string or returns None
if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 58 string or returns None
if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 58 string or throws an IllegalArgumentException if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 58 string or throws an IllegalArgumentException if the string is not valid base 58.
Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive.
The string may contain whitespace characters which are ignored.
- Throws
- IllegalArgumentException
if the string is not valid base 58
Constructs a BitVector
from a base 64 string or returns an error message if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 64 string or returns an error message if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 64 string or returns None
if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 64 string or returns None
if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 64 string or throws an IllegalArgumentException if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
Constructs a BitVector
from a base 64 string or throws an IllegalArgumentException if the string is not valid base 64.
Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive.
The string may contain whitespace characters which are ignored.
- Throws
- IllegalArgumentException
if the string is not valid base 64
Encodes the specified string to a BitVector
using the implicitly available Charset
.
Encodes the specified string to a BitVector
using the implicitly available Charset
.
Encodes the specified string to a BitVector
using the UTF-8 charset.
Encodes the specified string to a BitVector
using the UTF-8 charset.
Encodes the specified string to a BitVector
using the US-ASCII charset.
Encodes the specified string to a BitVector
using the US-ASCII charset.
Concatenates all the given BitVector
s into a single instance.
Concatenates all the given BitVector
s into a single instance.
Create a lazy BitVector
by repeatedly extracting chunks from S
.
The returned BitVector
will have the structure of a fully lazy
right-associated cons list. Thus, get
, take
, and drop
will
be efficient when operating on the head of the list, but accessing
later indices (for takeRight
, say, or get(size-1)
will require
forcing the stream up to that point.
Create a lazy BitVector
by repeatedly extracting chunks from S
.
The returned BitVector
will have the structure of a fully lazy
right-associated cons list. Thus, get
, take
, and drop
will
be efficient when operating on the head of the list, but accessing
later indices (for takeRight
, say, or get(size-1)
will require
forcing the stream up to that point.
Use force
if you wish to convert the result to an in-memory strict
BitVector
backed by a balanced tree.
Produce a lazy BitVector
from the given InputStream
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB).
This simply calls scodec.bits.BitVector.unfold with a function to extract a series
of flat byte arrays from the InputStream
.
Produce a lazy BitVector
from the given InputStream
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB).
This simply calls scodec.bits.BitVector.unfold with a function to extract a series
of flat byte arrays from the InputStream
.
This function does not handle closing the InputStream
and has all the usual
drawbacks of lazy I/O - I/O
exceptions may be raised unexpectedly in pure code as
chunks are forced, and it must memoize the results to prevent the underlying side
effects from being observed. Streaming applications should take care to ensure
that the head of the stream is not left on the stack, as this will cause the entire
stream to be retained in memory.
- Value Params
- chunkSizeInBytes
the number of bytes to read in each chunk
Produce a lazy BitVector
from the given ReadableByteChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB). This function
does lazy I/O, see scodec.bits.BitVector.fromInputStream for caveats. The direct
parameter, if true
, allows for (but does not enforce) using a 'direct' java.nio.ByteBuffer
for each chunk, which means the buffer and corresponding BitVector
chunk may be backed by a
'view' rather than an in-memory array. This may be more efficient for some workloads. See
java.nio.ByteBuffer
for more information.
Produce a lazy BitVector
from the given ReadableByteChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB). This function
does lazy I/O, see scodec.bits.BitVector.fromInputStream for caveats. The direct
parameter, if true
, allows for (but does not enforce) using a 'direct' java.nio.ByteBuffer
for each chunk, which means the buffer and corresponding BitVector
chunk may be backed by a
'view' rather than an in-memory array. This may be more efficient for some workloads. See
java.nio.ByteBuffer
for more information.
- Value Params
- chunkSizeInBytes
the number of bytes to read in each chunk
- direct
true if we should attempt to use a 'direct'
java.nio.ByteBuffer
for reads
Produce a lazy BitVector
from the given FileChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB). Unlike
scodec.bits.BitVector.fromChannel, this memory-maps chunks in, rather than copying
them explicitly.
Produce a lazy BitVector
from the given FileChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB). Unlike
scodec.bits.BitVector.fromChannel, this memory-maps chunks in, rather than copying
them explicitly.
Behavior is unspecified if this function is used concurrently with the underlying file being written.
- Value Params
- chunkSizeInBytes
the number of bytes to read in each chunk