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

NAME

6       Stdlib.Queue - no description
7

Module

9       Module   Stdlib.Queue
10

Documentation

12       Module Queue
13        : (module Stdlib__Queue)
14
15
16
17
18
19
20
21
22
23       Unsynchronized accesses
24
25       Unsynchronized  accesses to a queue may lead to an invalid queue state.
26       Thus, concurrent accesses to queues must be synchronized (for  instance
27       with a Mutex.t ).
28
29       type 'a t
30
31
32       The type of queues containing elements of type 'a .
33
34
35
36       exception Empty
37
38
39       Raised when Queue.take or Queue.peek is applied to an empty queue.
40
41
42
43       val create : unit -> 'a t
44
45       Return a new queue, initially empty.
46
47
48
49       val add : 'a -> 'a t -> unit
50
51
52       add x q adds the element x at the end of the queue q .
53
54
55
56       val push : 'a -> 'a t -> unit
57
58
59       push is a synonym for add .
60
61
62
63       val take : 'a t -> 'a
64
65
66       take  q  removes  and  returns the first element in queue q , or raises
67       Queue.Empty if the queue is empty.
68
69
70
71       val take_opt : 'a t -> 'a option
72
73
74       take_opt q removes and returns the first element in queue q  ,  or  re‐
75       turns None if the queue is empty.
76
77
78       Since 4.08
79
80
81
82       val pop : 'a t -> 'a
83
84
85       pop is a synonym for take .
86
87
88
89       val peek : 'a t -> 'a
90
91
92       peek  q returns the first element in queue q , without removing it from
93       the queue, or raises Queue.Empty if the queue is empty.
94
95
96
97       val peek_opt : 'a t -> 'a option
98
99
100       peek_opt q returns the first element in queue q , without  removing  it
101       from the queue, or returns None if the queue is empty.
102
103
104       Since 4.08
105
106
107
108       val top : 'a t -> 'a
109
110
111       top is a synonym for peek .
112
113
114
115       val clear : 'a t -> unit
116
117       Discard all elements from a queue.
118
119
120
121       val copy : 'a t -> 'a t
122
123       Return a copy of the given queue.
124
125
126
127       val is_empty : 'a t -> bool
128
129       Return true if the given queue is empty, false otherwise.
130
131
132
133       val length : 'a t -> int
134
135       Return the number of elements in a queue.
136
137
138
139       val iter : ('a -> unit) -> 'a t -> unit
140
141
142       iter  f  q  applies f in turn to all elements of q , from the least re‐
143       cently entered to the most recently entered.  The queue itself  is  un‐
144       changed.
145
146
147
148       val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
149
150
151       fold f accu q is equivalent to List.fold_left f accu l , where l is the
152       list of q 's elements. The queue remains unchanged.
153
154
155
156       val transfer : 'a t -> 'a t -> unit
157
158
159       transfer q1 q2 adds all of q1 's elements at the end of the queue q2  ,
160       then  clears q1 . It is equivalent to the sequence iter (fun x -> add x
161       q2) q1; clear q1 , but runs in constant time.
162
163
164
165
166   Iterators
167       val to_seq : 'a t -> 'a Seq.t
168
169       Iterate on the queue, in front-to-back  order.   The  behavior  is  not
170       specified if the queue is modified during the iteration.
171
172
173       Since 4.07
174
175
176
177       val add_seq : 'a t -> 'a Seq.t -> unit
178
179       Add the elements from a sequence to the end of the queue.
180
181
182       Since 4.07
183
184
185
186       val of_seq : 'a Seq.t -> 'a t
187
188       Create a queue from a sequence.
189
190
191       Since 4.07
192
193
194
195
196
197OCamldoc                          2023-07-20                   Stdlib.Queue(3)
Impressum