Retrieves the byte at the indicated index. Callers must prove that the index is in bounds. The index is represented by a platform-specific fixed-width integer (either 32 or 64 bits).
Because USize is big enough to address all memory on every platform that Lean supports, there are
in practice no ByteArrays for which uget cannot retrieve all elements.
Equations
Instances For
Retrieves the byte at the indicated index. Panics if the index is out of bounds.
Equations
Instances For
Replaces the byte at the given index.
No bounds check is performed, but the function requires a proof that the index is in bounds. This proof can usually be omitted, and will be synthesized automatically.
The array is modified in-place if there are no other references to it.
Equations
Instances For
Replaces the byte at the given index.
No bounds check is performed, but the function requires a proof that the index is in bounds. This proof can usually be omitted, and will be synthesized automatically.
The array is modified in-place if there are no other references to it.
Equations
Instances For
Computes a hash for a ByteArray.
Returns true when s contains zero bytes.
Equations
Instances For
Copies the slice at [srcOff, srcOff + len) in src to [destOff, destOff + len) in
dest, growing dest if necessary. If exact is false, the capacity
will be doubled when grown.
Equations
Instances For
Appends two byte arrays using fast array primitives instead of converting them into lists and back.
In compiled code, this function replaces calls to ByteArray.append.
Equations
Instances For
Converts a packed array of bytes to a linked list.
Equations
Instances For
Finds the index of the first byte in a for which p returns true. If no byte
in a satisfies p, then the result is none.
The index is returned along with a proof that it is a valid index in the array.
Equations
Instances For
Finds the index of the first byte in a for which p returns true. If no byte
in a satisfies p, then the result is none.
The variant findFinIdx? additionally returns a proof that the found index is in bounds.
Equations
Instances For
An efficient implementation of ForIn.forIn for ByteArray that uses USize
rather than Nat for indices.
We claim this unsafe implementation is correct because an array cannot have more than
USize.size elements in our runtime. This is similar to the Array version.
Equations
Instances For
The reference implementation of ForIn.forIn for ByteArray.
In compiled code, this is replaced by the more efficient ByteArray.forInUnsafe.
Equations
Instances For
An efficient implementation of a monadic left fold on for ByteArray that uses USize
rather than Nat for indices.
We claim this unsafe implementation is correct because an array cannot have more than
USize.size elements in our runtime. This is similar to the Array version.
Equations
Instances For
A monadic left fold on ByteArray that iterates over an array from low to high indices,
computing a running value.
Each element of the array is combined with the value from the prior elements using a monadic
function f. The initial value init is the starting value before any elements have
been processed.
Equations
Instances For
A left fold on ByteArray that iterates over an array from low to high indices, computing a
running value.
Each element of the array is combined with the value from the prior elements using a function
f. The initial value init is the starting value before any elements have been
processed.
ByteArray.foldlM is a monadic variant of this function.
Equations
Instances For
Iterator over the bytes (UInt8) of a ByteArray.
Typically created by arr.iter, where arr is a ByteArray.
An iterator is valid if the position i is valid for the array arr, meaning 0 ≤ i ≤ arr.size
Most operations on iterators return arbitrary values if the iterator is not valid. The functions in
the ByteArray.Iterator API should rule out the creation of invalid iterators, with two exceptions:
Iterator.next iteris invalid ifiteris already at the end of the array (iter.atEndistrue)Iterator.forward iter n/Iterator.nextn iter nis invalid ifnis strictly greater than the number of remaining bytes.
- array : ByteArray
The array the iterator is for.
- idx : Nat
The current position.
This position is not necessarily valid for the array, for instance if one keeps calling
Iterator.nextwhenIterator.atEndis true. If the position is not valid, then the current byte is(default : UInt8).
Instances For
Creates an iterator at the beginning of an array.
Equations
Instances For
Creates an iterator at the beginning of an array.
Equations
Instances For
The size of an array iterator is the number of bytes remaining.
Equations
The number of bytes remaining in the iterator.
Equations
Instances For
The current position.
This position is not necessarily valid for the array, for instance if one keeps calling
Iterator.next when Iterator.atEnd is true. If the position is not valid, then the
current byte is (default : UInt8).
Equations
Instances For
True if the iterator is past the array's last byte.
Equations
Instances For
The byte at the current position.
On an invalid position, returns (default : UInt8).
Equations
Instances For
Moves the iterator's position forward by one byte, unconditionally.
It is only valid to call this function if the iterator is not at the end of the array, i.e.
Iterator.atEnd is false; otherwise, the resulting iterator will be invalid.
Equations
Instances For
Decreases the iterator's position.
If the position is zero, this function is the identity.
Equations
Instances For
True if the iterator is valid; that is, it is not past the array's last byte.
Equations
Instances For
True if the position is not zero.
Equations
Instances For
Moves the iterator's position to the end of the array.
Given i : ByteArray.Iterator, note that i.toEnd.atEnd is always true.
Equations
Instances For
Moves the iterator's position several bytes forward.
The resulting iterator is only valid if the number of bytes to skip is less than or equal to the number of bytes left in the iterator.
Equations
Instances For
Moves the iterator's position several bytes forward.
The resulting iterator is only valid if the number of bytes to skip is less than or equal to the number of bytes left in the iterator.
Equations
Instances For
Moves the iterator's position several bytes back.
If asked to go back more bytes than available, stops at the beginning of the array.