Denys Duchier
This module provides a functional implemention of queues
The modules exports the following constructors:
{Queue.new ?Q}
Q
, currently
empty
{Queue.newFromList +L ?Q}
Q
, initialized
with the elements of list L
Each functional queue instance Q
has the following features:
{Q.get ?V}
V
available from Q
,
or raises exception empty
if none
{Q.put +V}
V
into the queue
{Q.getPut ?Old +New}
Old
available from Q
and enters the value New
. If Q
was empty, New
is Old
and Q
is still empty
{Q.top ?V}
V
available from Q
without actually removing it from Q
{Q.toList ?L}
L
of all values in Q
{Q.toListKill ?L}
L
of all values in Q
and makes Q
unusable until a subsequent {Q.reset}
.
This is more efficient that {Q.toList ?L}
because no copy
is required
{Q.isEmpty ?B}
Q
is empty
{Q.reset}
Q
's content and resets it to an empty queue
{Q.clone ?Q2}
Q2
which is
a clone of Q