Idris2Doc : Data.BoundedQueue.Unsized

Data.BoundedQueue.Unsized

(source)
Bounded Queues

Definitions

empty : Nat->BoundedQueuea
  The empty `BoundedQueue`. O(1)

Totality: total
Visibility: export
null : BoundedQueuea->Bool
  Is the `BoundedQueue` empty? O(1)

Totality: total
Visibility: export
fromList : Nat->Lista->BoundedQueuea
  Naively keeps the first `n` values of a list, and converts
into a `BoundedQueue` (keeps the order of the elements). O(1)

Totality: total
Visibility: export
fromSnocList : Nat->SnocLista->BoundedQueuea
  Naively keeps the first `n` values of a `SnocList`, and converts
into a `BoundedQueue` (keeps the order of the elements). O(1)

Totality: total
Visibility: export
toList : BoundedQueuea->Lista
  Converts a `BoundedQueue` to a `List`, keeping the order
of elements. O(n)

Totality: total
Visibility: export
toSnocList : BoundedQueuea->SnocLista
  Converts a `BoundedQueue` to a `SnocList`, keeping the order
of elements. O(n)

Totality: total
Visibility: export
enqueue : BoundedQueuea->a->BoundedQueuea
  Append a value at the back of the `BoundedQueue`. O(1)

Totality: total
Visibility: export
dequeue : BoundedQueuea->Maybe (a, BoundedQueuea)
  Take a value from the front of the `BoundedQueue`. O(1)

Totality: total
Visibility: export
prepend : a->BoundedQueuea->BoundedQueuea
  We can prepend an element to our `BoundedQueue`, making it the new
"oldest" element. O(1)

This is against the typical use case for a FIFO data
structure, but it allows us to conveniently implement
`peekOldest`.

Totality: total
Visibility: export
peekOldest : BoundedQueuea->Maybe (a, BoundedQueuea)
  Return the last element of the `BoundedQueue`, plus the unmodified
queue.

Note: `peekOldest` might involve a rearrangement of the elements
just like `dequeue`. In order to keep our amortized O(1)
runtime behavior, the newly arranged queue should be used
henceforth.

Totality: total
Visibility: export
(++) : BoundedQueuea->BoundedQueuea->BoundedQueuea
  Appends two `BoundedQueues`. O(m + n)

Totality: total
Visibility: export
Fixity Declaration: infixr operator, level 7
length : BoundedQueuea->Nat
  Returns the length of the `BoundedQueue`. O(1).

Totality: total
Visibility: export