Documentation

Batteries.Data.ByteSubarray

A subarray of a ByteArray.

  • array : ByteArray

    O(1). Get data array of a ByteSubarray.

  • start : Nat

    O(1). Get start index of a ByteSubarray.

  • stop : Nat

    O(1). Get stop index of a ByteSubarray.

  • 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
    theorem Batteries.ByteSubarray.start_le_stop (self : Batteries.ByteSubarray) :
    self.start self.stop

    Start index is before stop index.

    theorem Batteries.ByteSubarray.stop_le_array_size (self : Batteries.ByteSubarray) :
    self.stop self.array.size

    Stop index is before end of data array.

    O(1). Get the size of a ByteSubarray.

    Equations
    • self.size = self.stop - self.start
    Instances For

      O(1). Test if a ByteSubarray is empty.

      Equations
      • self.isEmpty = (self.start != self.stop)
      Instances For
        theorem Batteries.ByteSubarray.stop_eq_start_add_size (self : Batteries.ByteSubarray) :
        self.stop = self.start + self.size

        O(n). Extract a ByteSubarray to a ByteArray.

        Equations
        • self.toByteArray = self.array.extract self.start self.stop
        Instances For
          @[inline]

          O(1). Get the element at index i from the start of a ByteSubarray.

          Equations
          • self.get i = self.array[self.start + i]
          Instances For
            Equations
            @[inline]

            O(1). Pop the last element of a ByteSubarray.

            Equations
            • self.pop = if h : self.start = self.stop then self else { array := self.array, start := self.start, stop := self.stop - 1, start_le_stop := , stop_le_array_size := }
            Instances For
              @[inline]

              O(1). Pop the first element of a ByteSubarray.

              Equations
              • self.popFront = if h : self.start = self.stop then self else { array := self.array, start := self.start + 1, stop := self.stop, start_le_stop := , stop_le_array_size := }
              Instances For
                @[inline]
                def Batteries.ByteSubarray.foldlM {m : Type u_1 → Type u_2} {β : Type u_1} [Monad m] (self : Batteries.ByteSubarray) (f : βUInt8m β) (init : β) :
                m β

                Folds a monadic function over a ByteSubarray from left to right.

                Equations
                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
                    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
                      Instances For
                        Equations
                        • Batteries.ByteSubarray.instForInUInt8 = { forIn := fun {β : Type ?u.14} [Monad m] => Batteries.ByteSubarray.forIn }

                        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 := }
                        Instances For