1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the GNU Library General Public License. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-09-04 05:07:15 -07:00
|
|
|
(* Module [Queue]: first-in first-out queues *)
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
(* This module implements queues (FIFOs), with in-place modification. *)
|
|
|
|
|
|
|
|
type 'a t
|
|
|
|
(* The type of queues containing elements of type ['a]. *)
|
|
|
|
|
|
|
|
exception Empty
|
|
|
|
(* Raised when [take] is applied to an empty queue. *)
|
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
val create: unit -> 'a t
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Return a new queue, initially empty. *)
|
|
|
|
val add: 'a -> 'a t -> unit
|
|
|
|
(* [add x q] adds the element [x] at the end of the queue [q]. *)
|
|
|
|
val take: 'a t -> 'a
|
|
|
|
(* [take q] removes and returns the first element in queue [q],
|
|
|
|
or raises [Empty] if the queue is empty. *)
|
|
|
|
val peek: 'a t -> 'a
|
|
|
|
(* [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 t -> unit
|
|
|
|
(* Discard all elements from a queue. *)
|
|
|
|
val length: 'a t -> int
|
|
|
|
(* Return the number of elements in a queue. *)
|
2000-04-02 18:57:52 -07:00
|
|
|
val iter: f:('a -> unit) -> 'a t -> unit
|
1995-09-04 05:07:15 -07:00
|
|
|
(* [iter f q] applies [f] in turn to all elements of [q],
|
1995-08-09 06:15:01 -07:00
|
|
|
from the least recently entered to the most recently entered.
|
1995-05-04 03:15:53 -07:00
|
|
|
The queue itself is unchanged. *)
|