Documentation

ScalarArray.USize.Slice

Slices of USizeArray #

Slices of USizeArray: the type, reads, slice notation, iterators, folds and searches, membership and equality, and collecting iterators into arrays.

The slice type #

Internal representation of USizeArray.Slice.

  • array : USizeArray

    The underlying array.

  • start : Nat

    The starting index of the slice (inclusive).

  • stop : Nat

    The ending index of the slice (exclusive).

  • start_le_stop : self.start ≤ self.stop

    The starting index is no later than the ending index.

  • stop_le_array_size : self.stop ≤ self.array.size

    The ending index is no later than the end of the array.

Instances For
    @[reducible, inline]

    A region of a USizeArray: the elements from index start up to, but not including, stop. Taking a slice doesn't copy the array. Slices are written with core's slice notation, such as a[i...j], a[i...*] or a[*...j].

    Equations
    Instances For
      @[inline]

      The underlying array.

      Equations
      Instances For
        @[inline]

        The starting index of the slice (inclusive).

        Equations
        Instances For
          @[inline]

          The ending index of the slice (exclusive).

          Equations
          Instances For

            The starting index is no later than the ending index.

            The ending index is no later than the end of the array.

            Reads #

            @[inline]
            def ScalarArray.USizeArray.Slice.get (s : USizeArray.Slice) (i : Nat) (h : i < Std.Slice.size s := by get_elem_tactic) :

            The element at index i of the slice, counted from the start of the slice.

            Equations
            Instances For
              @[inline]

              The element at index i of the slice, or v₀ if i is out of bounds.

              Equations
              Instances For
                @[reducible, inline]

                The element at index i of the slice, or default if i is out of bounds.

                Equations
                Instances For
                  @[inline]

                  Removes the first element of the slice, if any.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    The empty slice, copies and printing #

                    The empty slice, backed by an empty array.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      The elements of the slice, copied into a new array with a single memmove.

                      Equations
                      Instances For
                        @[instance_reducible]

                        Prints the array and the bounds in slice notation, (ScalarArray.USizeArray.mk #[...])[i...j], which evaluates to an equal slice: slices are equal when their arrays and bounds are.

                        Equations
                        • One or more equations did not get rendered due to their size.

                        Slice notation #

                        @[inline]
                        def ScalarArray.USizeArray.toSlice (a : USizeArray) (start : Nat := 0) (stop : Nat := a.size) :

                        The slice of a from index start up to, but not including, stop. If start or stop are not valid bounds, they are clamped to the size of a, and start is clamped to stop.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          @[instance_reducible]

                          Arrays coerce to slices, which is free. Slices don't coerce back, since that copies.

                          Equations
                          @[inline]

                          The slice of s from index start up to, but not including, stop, clamped like toSlice.

                          Equations
                          Instances For

                            Iterators #

                            The iterator over the elements of a slice, used for for loops and the generic slice API.

                            Instances For
                              @[inline]

                              One step of the iterator: the first element of the rest of the slice, if there is one.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[instance_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.
                                @[implemented_by _private.ScalarArray.USize.Slice.0.ScalarArray.USizeArray.SliceIterator.forInImpl]
                                def ScalarArray.USizeArray.SliceIterator.forIn {n : Type x → Type x'} [Monad n] (lift : (γ : Type) → (δ : Type x) → (γ → n δ) → Id γ → n δ) (γ : Type x) (Pl : USize → γ → ForInStep γ → Prop) (it : Std.IterM Id USize) (init : γ) (f : (b : USize) → it.IsPlausibleIndirectOutput b → (c : γ) → n (Subtype (Pl b c))) :
                                n γ

                                The loop behind for loops and the Std.Iterators consumers on slices. Logically it is Std.IteratorLoop.defaultImplementation, which steps the iterator one element at a time; it is implemented by a loop over the USize indices of the underlying array.

                                Equations
                                Instances For
                                  @[instance_reducible]
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  @[instance_reducible]
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  @[inline]

                                  The elements that the slice iterator it has yet to yield, as a slice of the same array, without copying. The start of the slice is the index of the next element in the array.

                                  Equations
                                  Instances For
                                    @[inline]

                                    An iterator over the elements of a, for use with the Std.Iterators API.

                                    Equations
                                    Instances For

                                      Folds and searches #

                                      def ScalarArray.USizeArray.Slice.foldrM {β : Type v} {m : Type v → Type w} [Monad m] (f : USize → β → m β) (init : β) (s : USizeArray.Slice) :
                                      m β

                                      Folds a monadic function over the elements of s, from last to first.

                                      Equations
                                      Instances For
                                        @[specialize #[]]
                                        def ScalarArray.USizeArray.Slice.foldrM.loop {β : Type v} {m : Type v → Type w} [Monad m] (f : USize → β → m β) (s : USizeArray.Slice) (i : Nat) :
                                        i ≤ Std.Slice.size s → β → m β

                                        The loop of foldrM: folds f over the first i elements of s, from last to first.

                                        Equations
                                        Instances For
                                          @[inline]
                                          def ScalarArray.USizeArray.Slice.foldrMImpl {β : Type v} {m : Type v → Type w} [Monad m] (f : USize → β → m β) (init : β) (s : USizeArray.Slice) :
                                          m β

                                          For internal use only.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            @[inline]
                                            def ScalarArray.USizeArray.Slice.foldr {β : Type v} (f : USize → β → β) (init : β) (s : USizeArray.Slice) :
                                            β

                                            Folds a function over the elements of s, from last to first.

                                            Equations
                                            Instances For
                                              @[inline]

                                              Runs a monadic action on each element of s, from last to first.

                                              Equations
                                              Instances For
                                                def ScalarArray.USizeArray.Slice.findSomeRevM? {β : Type v} {m : Type v → Type w} [Monad m] (s : USizeArray.Slice) (f : USize → m (Option β)) :
                                                m (Option β)

                                                The result of the last element of s for which f returns some, searching from the end.

                                                Equations
                                                Instances For
                                                  @[specialize #[]]
                                                  def ScalarArray.USizeArray.Slice.findSomeRevM?.loop {β : Type v} {m : Type v → Type w} [Monad m] (s : USizeArray.Slice) (f : USize → m (Option β)) (i : Nat) :
                                                  i ≤ Std.Slice.size s → m (Option β)

                                                  The loop of findSomeRevM?: searches the first i elements of s, from the end.

                                                  Equations
                                                  Instances For
                                                    @[inline]
                                                    def ScalarArray.USizeArray.Slice.findSomeRevMImpl {β : Type v} {m : Type v → Type w} [Monad m] (s : USizeArray.Slice) (f : USize → m (Option β)) :
                                                    m (Option β)

                                                    For internal use only.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      @[inline]

                                                      The last element of s that satisfies the monadic predicate p.

                                                      Equations
                                                      Instances For
                                                        @[inline]

                                                        The last element of s that satisfies p.

                                                        Equations
                                                        Instances For
                                                          @[inline]

                                                          The first element of s that satisfies p.

                                                          Equations
                                                          Instances For
                                                            @[inline]

                                                            Whether some element of s satisfies p.

                                                            Equations
                                                            Instances For
                                                              @[inline]

                                                              Whether every element of s satisfies p.

                                                              Equations
                                                              Instances For
                                                                @[inline]

                                                                Whether some element of s is == to v.

                                                                Equations
                                                                Instances For
                                                                  @[inline]

                                                                  The number of elements of s that satisfy p.

                                                                  Equations
                                                                  Instances For

                                                                    Membership and equality #

                                                                    Compares the elements of two slices with ==: slices of different arrays, or at different offsets, are equal when their elements are. Logically it compares the copies.

                                                                    Equations
                                                                    Instances For

                                                                      For internal use only.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        Collecting iterators into arrays #

                                                                        @[inline]

                                                                        Collects the values emitted by an iterator into a new array. Together with the Std.Iterators combinators, this gives functions such as map, filter, take and zipWith, for example (a.iter.map (· + 1)).toUSizeArray.

                                                                        Equations
                                                                        Instances For
                                                                          @[inline]

                                                                          Like Std.Iter.toUSizeArray, but the new array starts with room for capacity elements.

                                                                          Equations
                                                                          Instances For