Equations
- ByteArray.instBEq.beq { data := a } { data := b } = (a == b)
- ByteArray.instBEq.beq x✝¹ x✝ = false
Instances For
Equations
- ByteArray.instBEq = { beq := ByteArray.instBEq.beq }
Equations
Instances For
Instances For
Equations
Instances For
Equations
- ByteArray.instInhabited = { default := ByteArray.empty }
Equations
- ByteArray.instEmptyCollection = { emptyCollection := ByteArray.empty }
Equations
- ByteArray.instHashable = { hash := ByteArray.hash }
Copy 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
- One or more equations did not get rendered due to their size.
Instances For
Equations
- a.extract b e = a.copySlice b ByteArray.empty 0 (e - b)
Instances For
Equations
- ByteArray.instAppend = { append := ByteArray.append }
Equations
- bs.toList = ByteArray.toList.loop bs 0 []
Instances For
Equations
- a.findFinIdx? p start = ByteArray.findFinIdx?.loop a p start
Instances For
Equations
Instances For
We claim this unsafe implementation is correct because an array cannot have more than usizeSz elements in our runtime.
This is similar to the Array version.
TODO: avoid code duplication in the future after we improve the compiler.
Equations
- as.forInUnsafe b f = ByteArray.forInUnsafe.loop as f as.usize 0 b
Instances For
Equations
- ByteArray.instForInUInt8 = { forIn := fun {β : Type ?u.10} [Monad m] => ByteArray.forIn }
Reference implementation for foldlM
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ByteArray.foldl f init as start stop = (ByteArray.foldlM (fun (x1 : β) (x2 : UInt8) => pure (f x1 x2)) init as start stop).run
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
Instances For
Equations
Creates an iterator at the beginning of an array.
Equations
- arr.mkIterator = { array := arr, idx := 0 }
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
- ByteArray.instSizeOfIterator = { sizeOf := fun (i : ByteArray.Iterator) => i.array.size - i.idx }
Number of bytes remaining in the iterator.
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).
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.
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.
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.
Instances For
Equations
- List.toByteArray.loop [] x✝ = x✝
- List.toByteArray.loop (b :: bs) x✝ = List.toByteArray.loop bs (x✝.push b)