Constructs a ByteVector
from a binary string or returns None
if the string is not valid binary.
Constructs a ByteVector
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 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.
Produce a lazy BitVector
from the given ReadableByteChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 8k).
Produce a lazy BitVector
from the given ReadableByteChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 8k). This function
does lazy I/O, see scodec.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.
the number of bytes to read in each chunk
true if we should attempt to use a 'direct' java.nio.ByteBuffer for reads
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 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.
Produce a lazy BitVector
from the given InputStream
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 4MB).
Produce a lazy BitVector
from the given InputStream
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 4MB).
This simply calls scodec.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.
the number of bytes to read in each chunk
Produce a lazy BitVector
from the given FileChannel
, using chunkSizeInBytes
to control the number of bytes read in each chunk (defaulting to 16MB).
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.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.
the number of bytes to read in each chunk
Constructs a ByteVector
from a binary string or throws an IllegalArgumentException if the string is not valid binary.
Constructs a ByteVector
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.
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.
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.
if the string is not valid hexadecimal
Create a lazy BitVector
by repeatedly extracting chunks from S
.
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.
Like apply
, but no copy of the underlying array is made.
Like apply
, but no copy of the underlying ByteBuffer
is made.
Like apply
, but no copy of the underlying ByteBuffer
is made.
Like apply
, but no copy of the underlying ByteBuffer
is made. Uses buffer.limit
to compute the size.
Companion for BitVector.