type (='a:type, ='b:level, #'c:level) t
The type of queues containing elements of type 'a
.
exception Empty
Raised when Queue.take
or Queue.peek
is applied to an empty queue.
val create : unit -> ('a, 'b, 'c) t
Return a new queue, initially empty.
val add : 'a -> ('a, 'b, 'b) t -{'b ||}-> unit
add x q
adds the element x
at the end of the queue q
.
val take : ('a, 'b, 'b) t -{'c | Empty: 'd |}-> 'e
with 'a < 'e
and 'c < 'b, 'd, level('e)
and 'b < 'd, level('e)
take q
removes and returns the first element in queue q
,
or raises Empty
if the queue is empty.
val peek : ('a, 'b, 'c) t -{'d | Empty: 'd |}-> 'e
with 'a < 'e
and 'c < 'd, level('e)
and 'b < 'd, level('e)
peek q
returns the first element in queue q
, without removing
it from the queue, or raises Empty
if the queue is empty.
val clear : ('a, 'b, 'b) t -{'b ||}-> unit
Discard all elements from a queue.
val length : ('a, 'b, 'c) t -> 'c int
with 'b < 'c
Return the number of elements in a queue.
val iter : ('a -{'b | 'c | 'b}-> 'd) -> ('a, 'e, 'b) t -{'b | 'c |}-> unit
with content('c), 'e < 'b
iter f q
applies f
in turn to all elements of q
,
from the least recently entered to the most recently entered.
The queue itself is unchanged.
This module implements queues (FIFOs), with in-place modification.