@grain/stdlib 0.5.13 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +201 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +62 -40
- package/hash.md +27 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2071 -0
- package/json.md +646 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +193 -174
- package/runtime/numberUtils.md +29 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +543 -245
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/queue.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
title: Queue
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A queue is a FIFO (first-in-first-out) data structure where new
|
|
6
|
+
values are added to the end and retrieved or removed from the beginning.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
The default implementation is mutable, but an immutable queue
|
|
9
|
+
implementation is available in the `Immutable` submodule.
|
|
8
10
|
|
|
9
11
|
<details disabled>
|
|
10
12
|
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
@@ -12,7 +14,7 @@ No other changes yet.
|
|
|
12
14
|
</details>
|
|
13
15
|
|
|
14
16
|
```grain
|
|
15
|
-
|
|
17
|
+
from "queue" include Queue
|
|
16
18
|
```
|
|
17
19
|
|
|
18
20
|
## Types
|
|
@@ -25,53 +27,386 @@ Type declarations included in the Queue module.
|
|
|
25
27
|
type Queue<a>
|
|
26
28
|
```
|
|
27
29
|
|
|
30
|
+
A mutable FIFO (first-in-first-out) data structure.
|
|
31
|
+
|
|
28
32
|
## Values
|
|
29
33
|
|
|
30
|
-
Functions and constants
|
|
34
|
+
Functions and constants included in the Queue module.
|
|
31
35
|
|
|
32
|
-
### Queue.**
|
|
36
|
+
### Queue.**make**
|
|
33
37
|
|
|
34
38
|
<details disabled>
|
|
35
|
-
<summary tabindex="-1">Added in <code>0.
|
|
39
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
36
40
|
No other changes yet.
|
|
37
41
|
</details>
|
|
38
42
|
|
|
39
43
|
```grain
|
|
40
|
-
|
|
44
|
+
make : (?size: Number) => Queue<a>
|
|
41
45
|
```
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
Creates a new queue with an initial storage of the given size. As values are
|
|
48
|
+
added or removed, the internal storage may grow or shrink. Generally, you
|
|
49
|
+
won’t need to care about the storage size of your map and can use the
|
|
50
|
+
default size.
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
Parameters:
|
|
53
|
+
|
|
54
|
+
|param|type|description|
|
|
55
|
+
|-----|----|-----------|
|
|
56
|
+
|`?size`|`Number`|The initial storage size of the queue|
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
|type|description|
|
|
61
|
+
|----|-----------|
|
|
62
|
+
|`Queue<a>`|An empty queue|
|
|
63
|
+
|
|
64
|
+
### Queue.**isEmpty**
|
|
48
65
|
|
|
49
66
|
<details disabled>
|
|
50
|
-
<summary tabindex="-1">Added in <code>0.
|
|
67
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
51
68
|
No other changes yet.
|
|
52
69
|
</details>
|
|
53
70
|
|
|
54
71
|
```grain
|
|
55
|
-
|
|
72
|
+
isEmpty : (queue: Queue<a>) => Bool
|
|
56
73
|
```
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
Checks if the given queue contains no items.
|
|
76
|
+
|
|
77
|
+
Parameters:
|
|
78
|
+
|
|
79
|
+
|param|type|description|
|
|
80
|
+
|-----|----|-----------|
|
|
81
|
+
|`queue`|`Queue<a>`|The queue to check|
|
|
59
82
|
|
|
60
83
|
Returns:
|
|
61
84
|
|
|
62
85
|
|type|description|
|
|
63
86
|
|----|-----------|
|
|
64
|
-
|`
|
|
87
|
+
|`Bool`|`true` if the queue has no items or `false` otherwise|
|
|
65
88
|
|
|
66
|
-
### Queue.**
|
|
89
|
+
### Queue.**size**
|
|
67
90
|
|
|
68
91
|
<details disabled>
|
|
69
|
-
<summary tabindex="-1">Added in <code>0.
|
|
92
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
93
|
+
No other changes yet.
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
```grain
|
|
97
|
+
size : (queue: Queue<a>) => Number
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Computes the size of the input queue.
|
|
101
|
+
|
|
102
|
+
Parameters:
|
|
103
|
+
|
|
104
|
+
|param|type|description|
|
|
105
|
+
|-----|----|-----------|
|
|
106
|
+
|`queue`|`Queue<a>`|The queue to inspect|
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
|
|
110
|
+
|type|description|
|
|
111
|
+
|----|-----------|
|
|
112
|
+
|`Number`|The count of the items in the queue|
|
|
113
|
+
|
|
114
|
+
### Queue.**peek**
|
|
115
|
+
|
|
116
|
+
<details disabled>
|
|
117
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
118
|
+
No other changes yet.
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
```grain
|
|
122
|
+
peek : (queue: Queue<a>) => Option<a>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Provides the value at the beginning of the queue, if it exists.
|
|
126
|
+
|
|
127
|
+
Parameters:
|
|
128
|
+
|
|
129
|
+
|param|type|description|
|
|
130
|
+
|-----|----|-----------|
|
|
131
|
+
|`queue`|`Queue<a>`|The queue to inspect|
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
|
|
135
|
+
|type|description|
|
|
136
|
+
|----|-----------|
|
|
137
|
+
|`Option<a>`|`Some(value)` containing the value at the beginning of the queue or `None` otherwise.|
|
|
138
|
+
|
|
139
|
+
### Queue.**push**
|
|
140
|
+
|
|
141
|
+
<details disabled>
|
|
142
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
143
|
+
No other changes yet.
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
```grain
|
|
147
|
+
push : (value: a, queue: Queue<a>) => Void
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Adds a new item to the end of the queue.
|
|
151
|
+
|
|
152
|
+
Parameters:
|
|
153
|
+
|
|
154
|
+
|param|type|description|
|
|
155
|
+
|-----|----|-----------|
|
|
156
|
+
|`value`|`a`|The item to be added|
|
|
157
|
+
|`queue`|`Queue<a>`|The queue being updated|
|
|
158
|
+
|
|
159
|
+
### Queue.**pop**
|
|
160
|
+
|
|
161
|
+
<details disabled>
|
|
162
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
163
|
+
No other changes yet.
|
|
164
|
+
</details>
|
|
165
|
+
|
|
166
|
+
```grain
|
|
167
|
+
pop : (queue: Queue<a>) => Option<a>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Removes the item at the beginning of the queue.
|
|
171
|
+
|
|
172
|
+
Parameters:
|
|
173
|
+
|
|
174
|
+
|param|type|description|
|
|
175
|
+
|-----|----|-----------|
|
|
176
|
+
|`queue`|`Queue<a>`|The queue being updated|
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
|
|
180
|
+
|type|description|
|
|
181
|
+
|----|-----------|
|
|
182
|
+
|`Option<a>`|The element removed from the queue|
|
|
183
|
+
|
|
184
|
+
### Queue.**toList**
|
|
185
|
+
|
|
186
|
+
<details disabled>
|
|
187
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
188
|
+
No other changes yet.
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
```grain
|
|
192
|
+
toList : (queue: Queue<a>) => List<a>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Converts a queue into a list of its elements.
|
|
196
|
+
|
|
197
|
+
Parameters:
|
|
198
|
+
|
|
199
|
+
|param|type|description|
|
|
200
|
+
|-----|----|-----------|
|
|
201
|
+
|`queue`|`Queue<a>`|The queue to convert|
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
|
|
205
|
+
|type|description|
|
|
206
|
+
|----|-----------|
|
|
207
|
+
|`List<a>`|A list containing all queue values|
|
|
208
|
+
|
|
209
|
+
### Queue.**fromList**
|
|
210
|
+
|
|
211
|
+
<details disabled>
|
|
212
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
213
|
+
No other changes yet.
|
|
214
|
+
</details>
|
|
215
|
+
|
|
216
|
+
```grain
|
|
217
|
+
fromList : (list: List<a>) => Queue<a>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Creates a queue from a list.
|
|
221
|
+
|
|
222
|
+
Parameters:
|
|
223
|
+
|
|
224
|
+
|param|type|description|
|
|
225
|
+
|-----|----|-----------|
|
|
226
|
+
|`list`|`List<a>`|The list to convert|
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
|
|
230
|
+
|type|description|
|
|
231
|
+
|----|-----------|
|
|
232
|
+
|`Queue<a>`|A queue containing all list values|
|
|
233
|
+
|
|
234
|
+
### Queue.**clear**
|
|
235
|
+
|
|
236
|
+
<details disabled>
|
|
237
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
238
|
+
No other changes yet.
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
```grain
|
|
242
|
+
clear : (queue: Queue<a>) => Void
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Clears the queue by removing all of its elements
|
|
246
|
+
|
|
247
|
+
Parameters:
|
|
248
|
+
|
|
249
|
+
|param|type|description|
|
|
250
|
+
|-----|----|-----------|
|
|
251
|
+
|`queue`|`Queue<a>`|The queue to clear|
|
|
252
|
+
|
|
253
|
+
### Queue.**copy**
|
|
254
|
+
|
|
255
|
+
<details disabled>
|
|
256
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
257
|
+
No other changes yet.
|
|
258
|
+
</details>
|
|
259
|
+
|
|
260
|
+
```grain
|
|
261
|
+
copy : (queue: Queue<a>) => Queue<a>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Produces a shallow copy of the input queue.
|
|
265
|
+
|
|
266
|
+
Parameters:
|
|
267
|
+
|
|
268
|
+
|param|type|description|
|
|
269
|
+
|-----|----|-----------|
|
|
270
|
+
|`queue`|`Queue<a>`|The queue to copy|
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
|
|
274
|
+
|type|description|
|
|
275
|
+
|----|-----------|
|
|
276
|
+
|`Queue<a>`|A new queue containing the elements from the input|
|
|
277
|
+
|
|
278
|
+
### Queue.**toArray**
|
|
279
|
+
|
|
280
|
+
<details disabled>
|
|
281
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
282
|
+
No other changes yet.
|
|
283
|
+
</details>
|
|
284
|
+
|
|
285
|
+
```grain
|
|
286
|
+
toArray : (queue: Queue<a>) => Array<a>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Converts a queue into an array of its values.
|
|
290
|
+
|
|
291
|
+
Parameters:
|
|
292
|
+
|
|
293
|
+
|param|type|description|
|
|
294
|
+
|-----|----|-----------|
|
|
295
|
+
|`queue`|`Queue<a>`|The queue to convert|
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
|
|
299
|
+
|type|description|
|
|
300
|
+
|----|-----------|
|
|
301
|
+
|`Array<a>`|An array containing all values from the given queue|
|
|
302
|
+
|
|
303
|
+
### Queue.**fromArray**
|
|
304
|
+
|
|
305
|
+
<details disabled>
|
|
306
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
307
|
+
No other changes yet.
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
```grain
|
|
311
|
+
fromArray : (arr: Array<a>) => Queue<a>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Creates a queue from an array.
|
|
315
|
+
|
|
316
|
+
Parameters:
|
|
317
|
+
|
|
318
|
+
|param|type|description|
|
|
319
|
+
|-----|----|-----------|
|
|
320
|
+
|`arr`|`Array<a>`|The array to convert|
|
|
321
|
+
|
|
322
|
+
Returns:
|
|
323
|
+
|
|
324
|
+
|type|description|
|
|
325
|
+
|----|-----------|
|
|
326
|
+
|`Queue<a>`|A queue containing all values from the array|
|
|
327
|
+
|
|
328
|
+
### Queue.**(==)**
|
|
329
|
+
|
|
330
|
+
<details disabled>
|
|
331
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
70
332
|
No other changes yet.
|
|
71
333
|
</details>
|
|
72
334
|
|
|
73
335
|
```grain
|
|
74
|
-
|
|
336
|
+
(==) : (queue1: Queue<a>, queue2: Queue<a>) => Bool
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Checks if two queues are equivalent by value.
|
|
340
|
+
|
|
341
|
+
Parameters:
|
|
342
|
+
|
|
343
|
+
|param|type|description|
|
|
344
|
+
|-----|----|-----------|
|
|
345
|
+
|`queue1`|`Queue<a>`|The first queue to compare|
|
|
346
|
+
|`queue2`|`Queue<a>`|The second queue to compare|
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
|
|
350
|
+
|type|description|
|
|
351
|
+
|----|-----------|
|
|
352
|
+
|`Bool`|`true` if the queues are equivalent or `false` otherwise|
|
|
353
|
+
|
|
354
|
+
## Queue.Immutable
|
|
355
|
+
|
|
356
|
+
An immutable queue implementation.
|
|
357
|
+
|
|
358
|
+
### Types
|
|
359
|
+
|
|
360
|
+
Type declarations included in the Queue.Immutable module.
|
|
361
|
+
|
|
362
|
+
#### Queue.Immutable.**ImmutableQueue**
|
|
363
|
+
|
|
364
|
+
```grain
|
|
365
|
+
type ImmutableQueue<a>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
An immutable FIFO (first-in-first-out) data structure.
|
|
369
|
+
|
|
370
|
+
### Values
|
|
371
|
+
|
|
372
|
+
Functions and constants included in the Queue.Immutable module.
|
|
373
|
+
|
|
374
|
+
#### Queue.Immutable.**empty**
|
|
375
|
+
|
|
376
|
+
<details>
|
|
377
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
378
|
+
<table>
|
|
379
|
+
<thead>
|
|
380
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
381
|
+
</thead>
|
|
382
|
+
<tbody>
|
|
383
|
+
<tr><td><code>0.5.4</code></td><td>Originally a module root API</td></tr>
|
|
384
|
+
</tbody>
|
|
385
|
+
</table>
|
|
386
|
+
</details>
|
|
387
|
+
|
|
388
|
+
```grain
|
|
389
|
+
empty : ImmutableQueue<a>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
An empty queue.
|
|
393
|
+
|
|
394
|
+
#### Queue.Immutable.**isEmpty**
|
|
395
|
+
|
|
396
|
+
<details>
|
|
397
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
398
|
+
<table>
|
|
399
|
+
<thead>
|
|
400
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
401
|
+
</thead>
|
|
402
|
+
<tbody>
|
|
403
|
+
<tr><td><code>0.2.0</code></td><td>Originally a module root API</td></tr>
|
|
404
|
+
</tbody>
|
|
405
|
+
</table>
|
|
406
|
+
</details>
|
|
407
|
+
|
|
408
|
+
```grain
|
|
409
|
+
isEmpty : (queue: ImmutableQueue<a>) => Bool
|
|
75
410
|
```
|
|
76
411
|
|
|
77
412
|
Checks if the given queue contains any values.
|
|
@@ -80,7 +415,7 @@ Parameters:
|
|
|
80
415
|
|
|
81
416
|
|param|type|description|
|
|
82
417
|
|-----|----|-----------|
|
|
83
|
-
|`queue`|`
|
|
418
|
+
|`queue`|`ImmutableQueue<a>`|The queue to check|
|
|
84
419
|
|
|
85
420
|
Returns:
|
|
86
421
|
|
|
@@ -88,10 +423,10 @@ Returns:
|
|
|
88
423
|
|----|-----------|
|
|
89
424
|
|`Bool`|`true` if the given queue is empty or `false` otherwise|
|
|
90
425
|
|
|
91
|
-
|
|
426
|
+
#### Queue.Immutable.**peek**
|
|
92
427
|
|
|
93
428
|
<details>
|
|
94
|
-
<summary>Added in <code>0.
|
|
429
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
95
430
|
<table>
|
|
96
431
|
<thead>
|
|
97
432
|
<tr><th>version</th><th>changes</th></tr>
|
|
@@ -99,13 +434,14 @@ Returns:
|
|
|
99
434
|
<tbody>
|
|
100
435
|
<tr><td><code>0.2.0</code></td><td>Originally named `head`</td></tr>
|
|
101
436
|
<tr><td><code>0.3.2</code></td><td>Deprecated `head` function</td></tr>
|
|
437
|
+
<tr><td><code>0.3.2</code></td><td>Originally a module root API</td></tr>
|
|
102
438
|
<tr><td><code>0.4.0</code></td><td>Removed `head` function</td></tr>
|
|
103
439
|
</tbody>
|
|
104
440
|
</table>
|
|
105
441
|
</details>
|
|
106
442
|
|
|
107
443
|
```grain
|
|
108
|
-
peek :
|
|
444
|
+
peek : (queue: ImmutableQueue<a>) => Option<a>
|
|
109
445
|
```
|
|
110
446
|
|
|
111
447
|
Returns the value at the beginning of the queue. It is not removed from the queue.
|
|
@@ -114,7 +450,7 @@ Parameters:
|
|
|
114
450
|
|
|
115
451
|
|param|type|description|
|
|
116
452
|
|-----|----|-----------|
|
|
117
|
-
|`queue`|`
|
|
453
|
+
|`queue`|`ImmutableQueue<a>`|The queue to inspect|
|
|
118
454
|
|
|
119
455
|
Returns:
|
|
120
456
|
|
|
@@ -122,10 +458,10 @@ Returns:
|
|
|
122
458
|
|----|-----------|
|
|
123
459
|
|`Option<a>`|`Some(value)` containing the value at the beginning of the queue, or `None` if the queue is empty|
|
|
124
460
|
|
|
125
|
-
|
|
461
|
+
#### Queue.Immutable.**push**
|
|
126
462
|
|
|
127
463
|
<details>
|
|
128
|
-
<summary>Added in <code>0.
|
|
464
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
129
465
|
<table>
|
|
130
466
|
<thead>
|
|
131
467
|
<tr><th>version</th><th>changes</th></tr>
|
|
@@ -133,13 +469,14 @@ Returns:
|
|
|
133
469
|
<tbody>
|
|
134
470
|
<tr><td><code>0.2.0</code></td><td>Originally named `enqueue`</td></tr>
|
|
135
471
|
<tr><td><code>0.3.2</code></td><td>Deprecated `enqueue` function</td></tr>
|
|
472
|
+
<tr><td><code>0.3.2</code></td><td>Originally a module root API</td></tr>
|
|
136
473
|
<tr><td><code>0.4.0</code></td><td>Removed `enqueue` function</td></tr>
|
|
137
474
|
</tbody>
|
|
138
475
|
</table>
|
|
139
476
|
</details>
|
|
140
477
|
|
|
141
478
|
```grain
|
|
142
|
-
push : (a,
|
|
479
|
+
push : (value: a, queue: ImmutableQueue<a>) => ImmutableQueue<a>
|
|
143
480
|
```
|
|
144
481
|
|
|
145
482
|
Adds a value to the end of the queue.
|
|
@@ -149,18 +486,18 @@ Parameters:
|
|
|
149
486
|
|param|type|description|
|
|
150
487
|
|-----|----|-----------|
|
|
151
488
|
|`value`|`a`|The value to append|
|
|
152
|
-
|`queue`|`
|
|
489
|
+
|`queue`|`ImmutableQueue<a>`|The queue to update|
|
|
153
490
|
|
|
154
491
|
Returns:
|
|
155
492
|
|
|
156
493
|
|type|description|
|
|
157
494
|
|----|-----------|
|
|
158
|
-
|`
|
|
495
|
+
|`ImmutableQueue<a>`|An updated queue|
|
|
159
496
|
|
|
160
|
-
|
|
497
|
+
#### Queue.Immutable.**pop**
|
|
161
498
|
|
|
162
499
|
<details>
|
|
163
|
-
<summary>Added in <code>0.
|
|
500
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
164
501
|
<table>
|
|
165
502
|
<thead>
|
|
166
503
|
<tr><th>version</th><th>changes</th></tr>
|
|
@@ -168,13 +505,14 @@ Returns:
|
|
|
168
505
|
<tbody>
|
|
169
506
|
<tr><td><code>0.2.0</code></td><td>Originally named `dequeue`</td></tr>
|
|
170
507
|
<tr><td><code>0.3.2</code></td><td>Deprecated `dequeue` function</td></tr>
|
|
508
|
+
<tr><td><code>0.3.2</code></td><td>Originally a module root API</td></tr>
|
|
171
509
|
<tr><td><code>0.4.0</code></td><td>Removed `dequeue` function</td></tr>
|
|
172
510
|
</tbody>
|
|
173
511
|
</table>
|
|
174
512
|
</details>
|
|
175
513
|
|
|
176
514
|
```grain
|
|
177
|
-
pop :
|
|
515
|
+
pop : (queue: ImmutableQueue<a>) => ImmutableQueue<a>
|
|
178
516
|
```
|
|
179
517
|
|
|
180
518
|
Dequeues the next value in the queue.
|
|
@@ -183,23 +521,30 @@ Parameters:
|
|
|
183
521
|
|
|
184
522
|
|param|type|description|
|
|
185
523
|
|-----|----|-----------|
|
|
186
|
-
|`queue`|`
|
|
524
|
+
|`queue`|`ImmutableQueue<a>`|The queue to change|
|
|
187
525
|
|
|
188
526
|
Returns:
|
|
189
527
|
|
|
190
528
|
|type|description|
|
|
191
529
|
|----|-----------|
|
|
192
|
-
|`
|
|
530
|
+
|`ImmutableQueue<a>`|An updated queue|
|
|
193
531
|
|
|
194
|
-
|
|
532
|
+
#### Queue.Immutable.**size**
|
|
195
533
|
|
|
196
|
-
<details
|
|
197
|
-
<summary
|
|
198
|
-
|
|
534
|
+
<details>
|
|
535
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
536
|
+
<table>
|
|
537
|
+
<thead>
|
|
538
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
539
|
+
</thead>
|
|
540
|
+
<tbody>
|
|
541
|
+
<tr><td><code>0.3.2</code></td><td>Originally a module root API</td></tr>
|
|
542
|
+
</tbody>
|
|
543
|
+
</table>
|
|
199
544
|
</details>
|
|
200
545
|
|
|
201
546
|
```grain
|
|
202
|
-
size :
|
|
547
|
+
size : (queue: ImmutableQueue<a>) => Number
|
|
203
548
|
```
|
|
204
549
|
|
|
205
550
|
Get the number of values in a queue.
|
|
@@ -208,7 +553,7 @@ Parameters:
|
|
|
208
553
|
|
|
209
554
|
|param|type|description|
|
|
210
555
|
|-----|----|-----------|
|
|
211
|
-
|`queue`|`
|
|
556
|
+
|`queue`|`ImmutableQueue<a>`|The queue to inspect|
|
|
212
557
|
|
|
213
558
|
Returns:
|
|
214
559
|
|
|
@@ -216,3 +561,53 @@ Returns:
|
|
|
216
561
|
|----|-----------|
|
|
217
562
|
|`Number`|The number of values in the queue|
|
|
218
563
|
|
|
564
|
+
#### Queue.Immutable.**toList**
|
|
565
|
+
|
|
566
|
+
<details disabled>
|
|
567
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
568
|
+
No other changes yet.
|
|
569
|
+
</details>
|
|
570
|
+
|
|
571
|
+
```grain
|
|
572
|
+
toList : (queue: ImmutableQueue<a>) => List<a>
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
Converts a queue into a list of its elements.
|
|
576
|
+
|
|
577
|
+
Parameters:
|
|
578
|
+
|
|
579
|
+
|param|type|description|
|
|
580
|
+
|-----|----|-----------|
|
|
581
|
+
|`queue`|`ImmutableQueue<a>`|The queue to convert|
|
|
582
|
+
|
|
583
|
+
Returns:
|
|
584
|
+
|
|
585
|
+
|type|description|
|
|
586
|
+
|----|-----------|
|
|
587
|
+
|`List<a>`|A list containing all queue values|
|
|
588
|
+
|
|
589
|
+
#### Queue.Immutable.**fromList**
|
|
590
|
+
|
|
591
|
+
<details disabled>
|
|
592
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
593
|
+
No other changes yet.
|
|
594
|
+
</details>
|
|
595
|
+
|
|
596
|
+
```grain
|
|
597
|
+
fromList : (list: List<a>) => ImmutableQueue<a>
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
Creates a queue from a list.
|
|
601
|
+
|
|
602
|
+
Parameters:
|
|
603
|
+
|
|
604
|
+
|param|type|description|
|
|
605
|
+
|-----|----|-----------|
|
|
606
|
+
|`list`|`List<a>`|The list to convert|
|
|
607
|
+
|
|
608
|
+
Returns:
|
|
609
|
+
|
|
610
|
+
|type|description|
|
|
611
|
+
|----|-----------|
|
|
612
|
+
|`ImmutableQueue<a>`|A queue containing all list values|
|
|
613
|
+
|