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 byte vector representing this vector's contents followed by the specified vector's contents.
Returns a new vector with the specified byte prepended.
Returns a new vector with the specified byte 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 ByteVector
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
bytes of this vector.
Returns a vector whose contents are the results of taking the first n
bytes of this vector.
If this vector does not contain at least n
bytes, an error message is returned.
take
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.
IndexOutOfBoundsException
if the specified index is not in [0, size)
Alias for toBitVector.
Allocate (unobservable) mutable scratch space at the end of this
ByteVector
, which will be used to support fast :+
and ++
of small vectors.
Allocate (unobservable) mutable scratch space at the end of this
ByteVector
, which will be used to support fast :+
and ++
of small vectors. A default chunk size is used.
Note that :+
, ++
, and drop
on the result of a call to buffer
are guaranteed to return another buffered ByteVector
.
Allocate (unobservable) mutable scratch space at the end of this
ByteVector
, with chunks of the given size, which will be used to
support fast :+
and ++
of small vectors.
Allocate (unobservable) mutable scratch space at the end of this
ByteVector
, with chunks of the given size, which will be used to
support fast :+
and ++
of small vectors.
Note that :+
, ++
, and drop
on the result of a call to buffer
are guaranteed to return another buffered ByteVector
, with the
same size scratch space.
Returns a vector with the same contents but represented as a single tree node internally.
Returns a vector with the same contents but represented as a single tree node internally.
This may involve copying data, but has the advantage that lookups index directly into a single node 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
bytes of this vector and decodes them with the specified function,
resulting in a vector of the remaining bytes and the decoded value.
Consumes the first n
bytes of this vector and decodes them with the specified function,
resulting in a vector of the remaining bytes and the decoded value. If this vector
does not have n
bytes or an error occurs while decoding, an error is returned instead.
Determines if the specified slice is in this vector.
Returns a vector with the same contents as this vector but with a single compacted node made up by evaluating all internal nodes and concatenating their values.
Copies size
bytes of this vector, starting at index offset
, to array xs
, beginning at index start
.
Copies the contents of this vector to array xs
, beginning at index start
.
Copies as many bytes as possible to the given ByteBuffer, starting from its current position.
Copies as many bytes as possible to the given ByteBuffer, starting from its current position. This method will not overflow the buffer.
a ByteBuffer to copy bytes to
the number of bytes actually copied
Copies the contents of this vector to OutputStream s
.
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 byte vector using the specified cipher and key.
Decrypts this byte vector using the specified cipher and key.
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.
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 byte vector.
Computes a digest of this byte vector.
digest to use
Computes a digest of this byte vector.
Computes a digest of this byte vector.
digest algorithm to use
Returns a vector of all bytes in this vector except the first n
bytes.
Returns a vector of all bytes in this vector except the first n
bytes.
The resulting vector's size is 0 max (size - n)
.
Returns a vector of all bytes in this vector except the last n
bytes.
Returns a vector of all bytes in this vector except the last n
bytes.
The resulting vector's size is 0 max (size - n)
.
Drops the longest prefix of this vector such that every byte of the prefix satisfies the specific predicate.
Encrypts this byte vector using the specified cipher and key.
Encrypts this byte vector using the specified cipher and key.
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 byte vector ends with the specified vector.
Returns true if the specified value is a ByteVector
with the same contents as this vector.
Returns true if the specified value is a ByteVector
with the same contents as this vector.
Applies a binary operator to a start value and all elements of this vector, going left to right.
Applies a binary operator to a start value and all elements of this vector, going left to right.
starting value
operator to apply
Applies a binary operator to a start value and all segments(views) of this ByteVector expressed as read-only ByteBuffer, going left to right.
Applies a binary operator to a start value and all segments(views) of this ByteVector expressed as read-only ByteBuffer, going left to right.
Starting value
operator to apply
Applies a binary operator to a start value and all elements of this vector, going right to left.
Applies a binary operator to a start value and all elements of this vector, going right to left.
starting value
operator to apply
Applies a binary operator to a start value and all segments(views) of this ByteVector expressed as read-only ByteBuffer, going right ot left.
Applies a binary operator to a start value and all segments(views) of this ByteVector expressed as read-only ByteBuffer, going right ot left.
Starting value
operator to apply
Applies the specified function to each element of this vector.
Gets the byte at the specified index.
Gets the byte at the specified index.
IndexOutOfBoundsException
if the specified index is not in [0, size)
Converts this vector in to a sequence of chunkSize
-byte vectors.
Converts this vector in to a sequence of chunkSize
-byte vectors.
Calculates the hash code of this vector.
Calculates the hash code of this vector. The result is cached.
Returns the first byte of this vector or throws if vector is emtpy.
Returns the first byte 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 byte pattern in this vector.
Finds the first index after from
of the specified byte pattern in this vector.
index of slice or -1 if not found
Finds the first index of the specified byte pattern in this vector.
Finds the first index of the specified byte pattern in this vector.
index of slice or -1 if not found
Decompresses this vector using ZLIB.
Decompresses this vector using ZLIB.
buffer size, in bytes, to use when compressing
if true, will assume no ZLIB header and checksum
Returns a vector of all bytes in this vector except the last byte.
Returns a vector with the specified byte inserted at the specified index.
Returns the number of bytes in this vector, or None
if the size does not
fit into an Int
.
Returns true if this vector has no bytes.
Returns the last byte in this vector or throws if vector is empty.
Returns the last byte in this vector or returns None
if vector is empty.
Alias for size.
Returns the byte at the specified index, or None
if the index is out of range.
Returns a vector where each byte is the result of applying the specified function to the corresponding byte in this vector.
Returns a vector where each byte is the result of applying the specified function to the corresponding byte in this vector. This method returns a view and hence, is O(1). Call compact generate a new strict vector.
Returns a vector where each byte is the result of applying the specified function to the corresponding byte in this vector.
Returns a vector where each byte is the result of applying the specified function to the corresponding byte in this vector. Only the least significant byte is used (the three most significant bytes are ignored). This method returns a view and hence, is O(1). Call compact generate a new strict vector.
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 bytes.
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
-bytes vector whose contents are 0 or more zero bytes followed by this vector's contents.
Returns an n
-bytes vector whose contents are 0 or more zero bytes followed by this vector's contents.
IllegalArgumentException
if n < size
Returns an n
-byte vector whose contents are this vector's contents followed by 0 or more zero bytes.
Returns an n
-byte vector whose contents are this vector's contents followed by 0 or more zero bytes.
IllegalArgumentException
if n < size
Alias for padRight
.
Alias for padRight
.
IllegalArgumentException
if n < size
Invokes compact
on any subtrees whose size is <= chunkSize
.
Returns a vector with the specified byte vector replacing bytes [idx, idx + b.size]
.
Returns a vector with the bytes of this vector in reverse order.
Returns a vector with the bytes of this vector in reverse order. This method returns a view and hence, is O(1). Call compact generate a new strict vector.
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 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 a vector made up of the bytes starting at index from
up to index until
.
Returns a vector with the specified byte vector inserted at the specified index.
Returns a pair of vectors that is equal to (take(n), drop(n))
.
Returns true if this byte vector starts with the specified vector.
Returns a vector of all bytes in this vector except the first byte.
Returns a vector of the first n
bytes of this vector.
Returns a vector of the first n
bytes of this vector.
The resulting vector's size is n min size
.
Note: if an n
-byte vector is required, use the acquire
method instead.
acquire
Returns a vector of the last n
bytes of this vector.
Returns a vector of the last n
bytes of this vector.
The resulting vector's size is n min size
.
Returns the longest prefix of this vector such that every byte satisfies the specific predicate.
Converts the contents of this vector to a byte array.
Converts the contents of this vector to a base 58 string using the specified alphabet.
Converts the contents of this vector to a base 58 string.
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.
Converts the contents of this byte vector to a binary string of size * 8
digits.
Converts the contents of this byte vector to a binary string of size * 8
digits.
Converts the contents of this vector to a bit vector of size * 8
bits.
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
Represents the contents of this vector as a read-only java.nio.ByteBuffer
.
Represents the contents of this vector as a read-only java.nio.ByteBuffer
.
The returned buffer is read-only 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.
Converts the contents of this byte vector to a hexadecimal string of size * 2
nibbles.
Converts the contents of this byte vector to a hexadecimal string of size * 2
nibbles.
Converts the contents of this vector to an IndexedSeq
.
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 an Iterable
.
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 64
Converts the contents of this vector to a Seq
.
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 ByteVector
.
Display the size and bytes of this ByteVector
.
For bit vectors beyond a certain size, only a hash of the
contents are shown.
Converts the contents of this byte vector to a UUID.
Converts the contents of this byte vector to a UUID.
IllegalArgumentException
if size is not exactly 16.
Returns a bitwise complement of this value.
Returns a bitwise complement of this value.
Collapse any buffered chunks at the end of this ByteVector
,
resulting in an unbuffered ByteVector
.
Returns a vector with the byte at the specified index replaced with the specified byte.
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 new vector where each byte is the result of evaluating the specified function against the bytes of this vector and the specified vector at the corresponding index.
Returns a new vector where each byte is the result of evaluating the specified function
against the bytes of this vector and the specified vector at the corresponding index.
The resulting vector has size this.size min other.size
.
This method returns a view and hence, is O(1). Call compact generate a new strict vector.
See zipWith This method returns a view and hence, is O(1).
See zipWith This method returns a view and hence, is O(1).
Returns a new vector where each byte is the result of evaluating the specified function against the bytes of this vector and the specified vector at the corresponding index.
Returns a new vector where each byte is the result of evaluating the specified function
against the bytes of this vector and the specified vector at the corresponding index.
The resulting vector has size this.size min other.size
.
Only the least significant byte is used (the three most significant bytes are ignored).
This method returns a view and hence, is O(1). Call compact generate a new strict vector.
See zipWithI This method returns a view and hence, is O(1).
See zipWithI This method returns a view and hence, is O(1).
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.
An immutable vector of bytes, backed by a balanced binary tree of chunks. Most operations are logarithmic in the depth of this tree, including
++
,:+
,+:
,update
, andinsert
. Where possible, operations return lazy views rather than copying any underlying bytes. Usecopy
to copy all underlying bytes to a fresh, array-backedByteVector
.Unless otherwise noted, operations follow the same naming as the scala standard library collections, though this class does not extend any of the standard scala collections. Use
toIndexedSeq
,toSeq
, ortoIterable
to obtain a regularscala.collection
type.