Module queues

Implementation of a queue. The underlying implementation uses a seq. Note: For inter thread communication use a Channel instead.

Types

Queue[T] = object
  data: seq[T]
  rd, wr, count, mask: int
a queue   Source

Procs

proc initQueue[T](initialSize = 4): Queue[T]
creates a new queue. initialSize needs to be a power of 2.   Source
proc len[T](q: Queue[T]): int
returns the number of elements of q.   Source
proc add[T](q: var Queue[T]; item: T)
adds an item to the end of the queue q.   Source
proc enqueue[T](q: var Queue[T]; item: T)
alias for the add operation.   Source
proc dequeue[T](q: var Queue[T]): T
removes and returns the first element of the queue q.   Source
proc `$`[T](q: Queue[T]): string
turns a queue into its string representation.   Source

Iterators

iterator items[T](q: Queue[T]): T
yields every element of q.   Source
iterator mitems[T](q: var Queue[T]): var T
yields every element of q.   Source