A subarray of a ByteArray
.
- array : ByteArray
O(1)
. Get data array of aByteSubarray
. - start : Nat
O(1)
. Get start index of aByteSubarray
. - stop : Nat
O(1)
. Get stop index of aByteSubarray
. - start_le_stop : self.start ≤ self.stop
Start index is before stop index.
- stop_le_array_size : self.stop ≤ self.array.size
Stop index is before end of data array.
Instances For
O(1)
. Get the size of a ByteSubarray
.
Instances For
O(1)
. Test if a ByteSubarray
is empty.
Instances For
O(n)
. Extract a ByteSubarray
to a ByteArray
.
Equations
- self.toByteArray = self.array.extract self.start self.stop
Instances For
instance
Batteries.ByteSubarray.instGetElemNatUInt8LtSize :
GetElem Batteries.ByteSubarray Nat UInt8 fun (self : Batteries.ByteSubarray) (i : Nat) => i < self.size
Equations
- Batteries.ByteSubarray.instGetElemNatUInt8LtSize = { getElem := fun (self : Batteries.ByteSubarray) (i : Nat) (h : i < self.size) => self.get ⟨i, h⟩ }
@[inline]
def
Batteries.ByteSubarray.foldlM
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
(self : Batteries.ByteSubarray)
(f : β → UInt8 → m β)
(init : β)
:
m β
Folds a monadic function over a ByteSubarray
from left to right.
Equations
- self.foldlM f init = ByteArray.foldlM f init self.array self.start self.stop
Instances For
@[inline]
def
Batteries.ByteSubarray.foldl
{β : Type u_1}
(self : Batteries.ByteSubarray)
(f : β → UInt8 → β)
(init : β)
:
β
Folds a function over a ByteSubarray
from left to right.
Equations
- self.foldl f init = self.foldlM f init
Instances For
@[specialize #[]]
def
Batteries.ByteSubarray.forIn
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
(self : Batteries.ByteSubarray)
(init : β)
(f : UInt8 → β → m (ForInStep β))
:
m β
Implementation of forIn
for a ByteSubarray
.
Equations
- self.forIn init f = Batteries.ByteSubarray.forIn.loop self f self.size ⋯ init
Instances For
def
Batteries.ByteSubarray.forIn.loop
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
(self : Batteries.ByteSubarray)
(f : UInt8 → β → m (ForInStep β))
(i : Nat)
(h : i ≤ self.size)
(b : β)
:
m β
Inner loop of the forIn
implementation for ByteSubarray
.
Equations
- One or more equations did not get rendered due to their size.
- Batteries.ByteSubarray.forIn.loop self f 0 x b = pure b
Instances For
Equations
- Batteries.ByteSubarray.instStreamUInt8 = { next? := fun (s : Batteries.ByteSubarray) => do let x ← s[0]? some (x, s.popFront) }
O(1)
. Coerce a byte array into a byte slice.
Equations
- array.toByteSubarray = { array := array, start := 0, stop := array.size, start_le_stop := ⋯, stop_le_array_size := ⋯ }