src/littlesugar/staticSeq

Types

StaticSeq[N; T] = object
  
This is similar to seq, but internal storage size is fixed to N and it can be allocated on stack. So you can add only N items to this. Uses array as internal storage.

Procs

func `==`[N: static int](x: StaticSeq; y: array[N, x.T]): bool
func `[]`(x: StaticSeq; i: Natural): lent x.T {.inline.}
func `[]`(x: var StaticSeq; i: Natural): var x.T {.inline.}
func `[]=`(x: var StaticSeq; i: Natural; val: sink x.T) {.inline.}
func add(x: var StaticSeq; item: sink x.T) {.inline.}
func clear(x: var StaticSeq) {.inline.}
func high(x: StaticSeq): int {.inline.}
func isFull(x: StaticSeq): bool {.inline.}
func len(x: StaticSeq): int {.inline.}
func setLen(x: var StaticSeq; newLen: Natural)
func toStaticSeq(src: static string): auto
func toStaticSeq[N: static Natural; T](src: static array[N, T]): StaticSeq[N, T]
func `{}=`(x: var StaticSeq; i: Natural; val: sink x.T) {.inline.}
This is similar to []=, but you can assign with i larger than or equal to len. But i must be smaller than x.N. When you assign with i larger than or equal to len, len is automatically extended to i + 1, and elements in between old len to new len has default values.

Iterators

iterator items(x: StaticSeq): lent x.T
iterator mitems(x: var StaticSeq): var x.T

Templates

template minimumSizeInt(N: static range[1 .. int.high]): untyped
template toOpenArray(x: StaticSeq; first, last: Natural): untyped
Returns openArray[T] so that you can pass a part of x to a openArray[T] parameter of procs.
template toOpenArray(x: StaticSeq; first: Natural = 0): untyped