Implementation of a queue. The underlying implementation uses a
seq.
TQueue[T] = object
data: seq[T]
rd, wr, count, mask: int
-
a queue
proc initQueue[T](initialSize = 4): TQueue[T]
-
creates a new queue. initialSize needs to be a power of 2.
proc len[T](q: TQueue[T]): int
-
returns the number of elements of q.
proc add[T](q: var TQueue[T]; item: T)
-
adds an item to the end of the queue q.
proc enqueue[T](q: var TQueue[T]; item: T)
-
alias for the add operation.
proc dequeue[T](q: var TQueue[T]): T
-
removes and returns the first element of the queue q.
proc `$`[T](q: TQueue[T]): string
-
turns a queue into its string representation.
iterator items[T](q: TQueue[T]): T
-
yields every element of q.