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