nim_iterator_stream_experiment/collections/seqstack

This module provides a stack implementation based on Nim's seq[T].

This API is purely functional, free of side effects.

Types

SeqStack[T] = object
  list: List[T]
Since 0.3.0.   Source Edit

Funcs

func seqStack[T](s: seq[T]): SeqStack[T]
Since 0.3.0.   Source Edit
func seqStack(T: typedesc): SeqStack[T]

Returns an empty stack.

Since 0.3.0.

  Source Edit
func seqStack[T](): SeqStack[T]

Returns an empty stack.

Since 0.3.0.

  Source Edit
func len[T](self: SeqStack[T]): Natural
Since 0.3.0.   Source Edit
func isEmpty[T](self: SeqStack[T]): bool
Since 0.3.0.   Source Edit
func top[T](self: SeqStack[T]): Optional[T]

If the stack is empty, an empty Optional will be returned.

Since 0.3.0.

  Source Edit
func push[T](self: SeqStack[T]; item: T): SeqStack[T]

Returns the updated stack.

Since 0.3.0.

  Source Edit
func pop[T](self: SeqStack[T]): tuple[stack: SeqStack[T], popped: Optional[T]]

If the stack is empty, result.popped will be an empty Optional.

Since 0.3.0.

  Source Edit