src/sliceutils/strides

Source   Edit  

Implementation of slices with non-1 increments.

Types

Stride[T; U] = object
  base*: T
  step*: U
The low bound of a slice that has an additional step property that describes the increment of the slice. Source   Edit  
StridedSlice[T; U; V] = HSlice[Stride[T, U], V]
An alias for a slice with the low bound being a stride. Source   Edit  

Procs

func `[]`[I: Ordinal; T, U, V: SomeNumber](s: StridedSlice[T, U, V];
    i: HSlice[BackwardsIndex, I]): auto {.inline.}
Returns s[i.a] .. s[i.b]. Source   Edit  
func `[]`[I: Ordinal; T, U, V: SomeNumber](s: StridedSlice[T, U, V];
    i: HSlice[I, BackwardsIndex]): auto {.inline.}
Returns s[i.a] .. s[i.b]. Source   Edit  
func `[]`[I: Ordinal; T, U, V: SomeNumber](s: StridedSlice[T, U, V];
    i: HSlice[I, I]): auto {.inline.}
Returns s[i.a] .. s[i.b]. Source   Edit  
func `[]`[I: Ordinal; T, U, V: SomeNumber](s: StridedSlice[T, U, V]; i: I): auto {.
    inline.}
Returns the number given at the i th iteration over s. Source   Edit  
func `[]`[T, U, V: SomeNumber](s: StridedSlice[T, U, V];
                               i: HSlice[BackwardsIndex, BackwardsIndex]): auto {.
    inline.}
Returns s[i.a] .. s[i.b]. Source   Edit  
func `[]`[T, U, V: SomeNumber](s: StridedSlice[T, U, V]; i: BackwardsIndex): auto {.
    inline.}
Returns the number given at the i th iteration starting from the end over s. Source   Edit  
func by[T, U, V: SomeNumber](s: HSlice[T, U]; step: U): StridedSlice[T, U, V] {.
    inline.}
Initializes a stride with over the slice s with step step. Source   Edit  
func by[T, U: SomeNumber](base: T; step: U): Stride[T, U] {.inline.}
Initializes a stride with base base and step step. Source   Edit  
func contains[T, U, V, W: SomeNumber](s: StridedSlice[T, U, V]; x: W): bool
Returns true if x is a value given by iterating over s. Requires W - T -> X and X mod U -> Y: SomeNumber, meaning you need math.mod for floats. Source   Edit  
func len[T, U, V: SomeNumber](s: StridedSlice[T, U, V]): int {.inline.}
Guess of number of iterations over s. Source   Edit  
func stride[T, U: SomeNumber](base: T; step: U): Stride[T, U] {.inline.}
Initializes a stride with base base and step step. Source   Edit  

Iterators

iterator items[T, U, V: SomeNumber](s: StridedSlice[T, U, V]): auto {.
    noSideEffect.}
Iterates over s. Source   Edit