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       Warning This module is not thread-safe: each Queue.t value must be pro‐
21       tected from concurrent access (e.g. with a Mutex.t ).  Failure to do so
22       can lead to a crash.
23
24
25
26
27
28       type 'a t
29
30
31       The type of queues containing elements of type 'a .
32
33
34
35       exception Empty
36
37
38       Raised when Queue.take or Queue.peek is applied to an empty queue.
39
40
41
42       val create : unit -> 'a t
43
44       Return a new queue, initially empty.
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       val push : 'a -> 'a t -> unit
56
57
58       push is a synonym for add .
59
60
61
62       val take : 'a t -> 'a
63
64
65       take  q  removes  and  returns the first element in queue q , or raises
66       Queue.Empty if the queue is empty.
67
68
69
70       val pop : 'a t -> 'a
71
72
73       pop is a synonym for take .
74
75
76
77       val peek : 'a t -> 'a
78
79
80       peek q returns the first element in queue q , without removing it  from
81       the queue, or raises Queue.Empty if the queue is empty.
82
83
84
85       val top : 'a t -> 'a
86
87
88       top is a synonym for peek .
89
90
91
92       val clear : 'a t -> unit
93
94       Discard all elements from a queue.
95
96
97
98       val copy : 'a t -> 'a t
99
100       Return a copy of the given queue.
101
102
103
104       val is_empty : 'a t -> bool
105
106       Return true if the given queue is empty, false otherwise.
107
108
109
110       val length : 'a t -> int
111
112       Return the number of elements in a queue.
113
114
115
116       val iter : ('a -> unit) -> 'a t -> unit
117
118
119       iter  f  q  applies  f  in  turn  to all elements of q , from the least
120       recently entered to the most recently entered.   The  queue  itself  is
121       unchanged.
122
123
124
125       val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
126
127
128       fold f accu q is equivalent to List.fold_left f accu l , where l is the
129       list of q 's elements. The queue remains unchanged.
130
131
132
133       val transfer : 'a t -> 'a t -> unit
134
135
136       transfer q1 q2 adds all of q1 's elements at the end of the queue q2  ,
137       then  clears q1 . It is equivalent to the sequence iter (fun x -> add x
138       q2) q1; clear q1 , but runs in constant time.
139
140
141
142
143       === Iterators ===
144
145
146       val to_seq : 'a t -> 'a Seq.t
147
148       Iterate on the queue, in front-to-back  order.   The  behavior  is  not
149       defined if the queue is modified during the iteration.
150
151
152       Since 4.07
153
154
155
156       val add_seq : 'a t -> 'a Seq.t -> unit
157
158       Add the elements from the generator to the end of the queue
159
160
161       Since 4.07
162
163
164
165       val of_seq : 'a Seq.t -> 'a t
166
167       Create an array from the generator
168
169
170       Since 4.07
171
172
173
174
175
176OCamldoc                          2019-02-02                          Queue(3)
Impressum