1Queue(3)                         OCaml library                        Queue(3)
2
3
4

NAME

6       Queue - First-in first-out queues.
7

Module

9       Module   Queue
10

Documentation

12       Module Queue
13        : sig end
14
15
16       First-in first-out queues.
17
18       This module implements queues (FIFOs), with in-place modification.
19
20
21
22
23
24
25       type 'a t
26
27
28       The type of queues containing elements of type 'a .
29
30
31
32
33       exception Empty
34
35
36       Raised when Queue.take or Queue.peek is applied to an empty queue.
37
38
39
40
41       val create : unit -> 'a t
42
43       Return a new queue, initially empty.
44
45
46
47
48       val add : 'a -> 'a t -> unit
49
50
51       add x q adds the element x at the end of the queue q .
52
53
54
55
56       val push : 'a -> 'a t -> unit
57
58
59       push is a synonym for add .
60
61
62
63
64       val take : 'a t -> 'a
65
66
67       take  q  removes  and  returns the first element in queue q , or raises
68       Empty if the queue is empty.
69
70
71
72
73       val pop : 'a t -> 'a
74
75
76       pop is a synonym for take .
77
78
79
80
81       val peek : 'a t -> 'a
82
83
84       peek q returns the first element in queue q , without removing it  from
85       the queue, or raises Empty if the queue is empty.
86
87
88
89
90       val top : 'a t -> 'a
91
92
93       top is a synonym for peek .
94
95
96
97
98       val clear : 'a t -> unit
99
100       Discard all elements from a queue.
101
102
103
104
105       val copy : 'a t -> 'a t
106
107       Return a copy of the given queue.
108
109
110
111
112       val is_empty : 'a t -> bool
113
114       Return true if the given queue is empty, false otherwise.
115
116
117
118
119       val length : 'a t -> int
120
121       Return the number of elements in a queue.
122
123
124
125
126       val iter : ('a -> unit) -> 'a t -> unit
127
128
129       iter  f  q  applies  f  in  turn  to all elements of q , from the least
130       recently entered to the most recently entered.   The  queue  itself  is
131       unchanged.
132
133
134
135
136       val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
137
138
139       fold f accu q is equivalent to List.fold_left f accu l , where l is the
140       list of q 's elements. The queue remains unchanged.
141
142
143
144
145       val transfer : 'a t -> 'a t -> unit
146
147
148       transfer q1 q2 adds all of q1 's elements at the end of the queue q2  ,
149       then  clears q1 . It is equivalent to the sequence iter (fun x -> add x
150       q2) q1; clear q1 , but runs in constant time.
151
152
153
154
155
156
157OCamldoc                          2010-01-29                          Queue(3)
Impressum