@grain/stdlib 0.6.6 → 0.7.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 +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/priorityqueue.gr
CHANGED
|
@@ -31,9 +31,9 @@ let swap = (i1, i2, array) => {
|
|
|
31
31
|
|
|
32
32
|
let get = (array, i) =>
|
|
33
33
|
Option.expect(
|
|
34
|
-
"Impossible: "
|
|
35
|
-
toString(i)
|
|
36
|
-
" in PriorityQueue's inner storage array is None",
|
|
34
|
+
"Impossible: "
|
|
35
|
+
++ toString(i)
|
|
36
|
+
++ " in PriorityQueue's inner storage array is None",
|
|
37
37
|
array[i]
|
|
38
38
|
)
|
|
39
39
|
|
|
@@ -47,8 +47,8 @@ let rec siftDown = (i, pq) => {
|
|
|
47
47
|
swapWithI = leftI
|
|
48
48
|
}
|
|
49
49
|
if (
|
|
50
|
-
rightI < pq.size
|
|
51
|
-
pq.comp(get(pq.array, rightI), get(pq.array, swapWithI)) < 0
|
|
50
|
+
rightI < pq.size
|
|
51
|
+
&& pq.comp(get(pq.array, rightI), get(pq.array, swapWithI)) < 0
|
|
52
52
|
) {
|
|
53
53
|
swapWithI = rightI
|
|
54
54
|
}
|
|
@@ -340,8 +340,8 @@ provide module Immutable {
|
|
|
340
340
|
children: [newNode, node2, ...node1.children],
|
|
341
341
|
}
|
|
342
342
|
} else if (
|
|
343
|
-
comp(node2.val, newNode.val) <= 0
|
|
344
|
-
comp(node2.val, node1.val) <= 0
|
|
343
|
+
comp(node2.val, newNode.val) <= 0
|
|
344
|
+
&& comp(node2.val, node1.val) <= 0
|
|
345
345
|
) {
|
|
346
346
|
{
|
|
347
347
|
val: node2.val,
|
package/priorityqueue.md
CHANGED
|
@@ -46,7 +46,7 @@ Functions and constants included in the PriorityQueue module.
|
|
|
46
46
|
</details>
|
|
47
47
|
|
|
48
48
|
```grain
|
|
49
|
-
make
|
|
49
|
+
make: (?compare: ((a, a) => Number), ?size: Number) => PriorityQueue<a>
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Creates a new priority queue with a given internal storage size and a
|
|
@@ -60,16 +60,16 @@ queue and can use the default size.
|
|
|
60
60
|
|
|
61
61
|
Parameters:
|
|
62
62
|
|
|
63
|
-
|param|type|description|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
| param | type | description |
|
|
64
|
+
| ---------- | ------------------ | ------------------------------------------------------- |
|
|
65
|
+
| `?compare` | `(a, a) => Number` | The comparator function used to indicate priority order |
|
|
66
|
+
| `?size` | `Number` | The initial storage size of the priority queue |
|
|
67
67
|
|
|
68
68
|
Returns:
|
|
69
69
|
|
|
70
|
-
|type|description|
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
| type | description |
|
|
71
|
+
| ------------------ | ----------------------- |
|
|
72
|
+
| `PriorityQueue<a>` | An empty priority queue |
|
|
73
73
|
|
|
74
74
|
Examples:
|
|
75
75
|
|
|
@@ -93,22 +93,22 @@ No other changes yet.
|
|
|
93
93
|
</details>
|
|
94
94
|
|
|
95
95
|
```grain
|
|
96
|
-
size
|
|
96
|
+
size: (pq: PriorityQueue<a>) => Number
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Gets the number of elements in a priority queue.
|
|
100
100
|
|
|
101
101
|
Parameters:
|
|
102
102
|
|
|
103
|
-
|param|type|description|
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
| param | type | description |
|
|
104
|
+
| ----- | ------------------ | ----------------------------- |
|
|
105
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to inspect |
|
|
106
106
|
|
|
107
107
|
Returns:
|
|
108
108
|
|
|
109
|
-
|type|description|
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
| type | description |
|
|
110
|
+
| -------- | -------------------------------------------- |
|
|
111
|
+
| `Number` | The number of elements in the priority queue |
|
|
112
112
|
|
|
113
113
|
### PriorityQueue.**isEmpty**
|
|
114
114
|
|
|
@@ -118,22 +118,22 @@ No other changes yet.
|
|
|
118
118
|
</details>
|
|
119
119
|
|
|
120
120
|
```grain
|
|
121
|
-
isEmpty
|
|
121
|
+
isEmpty: (pq: PriorityQueue<a>) => Bool
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
Determines if the priority queue contains no elements.
|
|
125
125
|
|
|
126
126
|
Parameters:
|
|
127
127
|
|
|
128
|
-
|param|type|description|
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
| param | type | description |
|
|
129
|
+
| ----- | ------------------ | --------------------------- |
|
|
130
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to check |
|
|
131
131
|
|
|
132
132
|
Returns:
|
|
133
133
|
|
|
134
|
-
|type|description|
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
| type | description |
|
|
135
|
+
| ------ | ----------------------------------------------------------- |
|
|
136
|
+
| `Bool` | `true` if the priority queue is empty and `false` otherwise |
|
|
137
137
|
|
|
138
138
|
### PriorityQueue.**push**
|
|
139
139
|
|
|
@@ -143,17 +143,17 @@ No other changes yet.
|
|
|
143
143
|
</details>
|
|
144
144
|
|
|
145
145
|
```grain
|
|
146
|
-
push
|
|
146
|
+
push: (val: a, pq: PriorityQueue<a>) => Void
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
Adds a new element to the priority queue.
|
|
150
150
|
|
|
151
151
|
Parameters:
|
|
152
152
|
|
|
153
|
-
|param|type|description|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
| param | type | description |
|
|
154
|
+
| ----- | ------------------ | ---------------------------------------- |
|
|
155
|
+
| `val` | `a` | The value to add into the priority queue |
|
|
156
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to update |
|
|
157
157
|
|
|
158
158
|
### PriorityQueue.**peek**
|
|
159
159
|
|
|
@@ -163,7 +163,7 @@ No other changes yet.
|
|
|
163
163
|
</details>
|
|
164
164
|
|
|
165
165
|
```grain
|
|
166
|
-
peek
|
|
166
|
+
peek: (pq: PriorityQueue<a>) => Option<a>
|
|
167
167
|
```
|
|
168
168
|
|
|
169
169
|
Retrieves the highest priority element in the priority queue. It is not
|
|
@@ -171,15 +171,15 @@ removed from the queue.
|
|
|
171
171
|
|
|
172
172
|
Parameters:
|
|
173
173
|
|
|
174
|
-
|param|type|description|
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
| param | type | description |
|
|
175
|
+
| ----- | ------------------ | ----------------------------- |
|
|
176
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to inspect |
|
|
177
177
|
|
|
178
178
|
Returns:
|
|
179
179
|
|
|
180
|
-
|type|description|
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
| type | description |
|
|
181
|
+
| ----------- | ---------------------------------------------------------------------------------------------- |
|
|
182
|
+
| `Option<a>` | `Some(value)` containing the highest priority element or `None` if the priority queue is empty |
|
|
183
183
|
|
|
184
184
|
### PriorityQueue.**pop**
|
|
185
185
|
|
|
@@ -189,22 +189,22 @@ No other changes yet.
|
|
|
189
189
|
</details>
|
|
190
190
|
|
|
191
191
|
```grain
|
|
192
|
-
pop
|
|
192
|
+
pop: (pq: PriorityQueue<a>) => Option<a>
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
Removes and retrieves the highest priority element in the priority queue.
|
|
196
196
|
|
|
197
197
|
Parameters:
|
|
198
198
|
|
|
199
|
-
|param|type|description|
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
| param | type | description |
|
|
200
|
+
| ----- | ------------------ | ----------------------------- |
|
|
201
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to inspect |
|
|
202
202
|
|
|
203
203
|
Returns:
|
|
204
204
|
|
|
205
|
-
|type|description|
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
| type | description |
|
|
206
|
+
| ----------- | ---------------------------------------------------------------------------------------------- |
|
|
207
|
+
| `Option<a>` | `Some(value)` containing the highest priority element or `None` if the priority queue is empty |
|
|
208
208
|
|
|
209
209
|
### PriorityQueue.**drain**
|
|
210
210
|
|
|
@@ -214,7 +214,7 @@ No other changes yet.
|
|
|
214
214
|
</details>
|
|
215
215
|
|
|
216
216
|
```grain
|
|
217
|
-
drain
|
|
217
|
+
drain: (pq: PriorityQueue<a>) => List<a>
|
|
218
218
|
```
|
|
219
219
|
|
|
220
220
|
Clears the priority queue and produces a list of all of the elements in the priority
|
|
@@ -222,15 +222,15 @@ queue in priority order.
|
|
|
222
222
|
|
|
223
223
|
Parameters:
|
|
224
224
|
|
|
225
|
-
|param|type|description|
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
| param | type | description |
|
|
226
|
+
| ----- | ------------------ | --------------------------- |
|
|
227
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to drain |
|
|
228
228
|
|
|
229
229
|
Returns:
|
|
230
230
|
|
|
231
|
-
|type|description|
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
| type | description |
|
|
232
|
+
| --------- | -------------------------------------------------------- |
|
|
233
|
+
| `List<a>` | A list of all elements in the priority in priority order |
|
|
234
234
|
|
|
235
235
|
### PriorityQueue.**fromArray**
|
|
236
236
|
|
|
@@ -247,7 +247,7 @@ Returns:
|
|
|
247
247
|
</details>
|
|
248
248
|
|
|
249
249
|
```grain
|
|
250
|
-
fromArray
|
|
250
|
+
fromArray:
|
|
251
251
|
(array: Array<a>, ?compare: ((a, a) => Number)) => PriorityQueue<a>
|
|
252
252
|
```
|
|
253
253
|
|
|
@@ -259,16 +259,16 @@ and a negative number if the first has less priority.
|
|
|
259
259
|
|
|
260
260
|
Parameters:
|
|
261
261
|
|
|
262
|
-
|param|type|description|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
| param | type | description |
|
|
263
|
+
| ---------- | ------------------ | --------------------------------------------------------- |
|
|
264
|
+
| `array` | `Array<a>` | An array of values used to initialize the priority queue |
|
|
265
|
+
| `?compare` | `(a, a) => Number` | A comparator function used to assign priority to elements |
|
|
266
266
|
|
|
267
267
|
Returns:
|
|
268
268
|
|
|
269
|
-
|type|description|
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
| type | description |
|
|
270
|
+
| ------------------ | ------------------------------------------------------- |
|
|
271
|
+
| `PriorityQueue<a>` | A priority queue containing the elements from the array |
|
|
272
272
|
|
|
273
273
|
### PriorityQueue.**fromList**
|
|
274
274
|
|
|
@@ -285,7 +285,7 @@ Returns:
|
|
|
285
285
|
</details>
|
|
286
286
|
|
|
287
287
|
```grain
|
|
288
|
-
fromList
|
|
288
|
+
fromList: (list: List<a>, ?compare: ((a, a) => Number)) => PriorityQueue<a>
|
|
289
289
|
```
|
|
290
290
|
|
|
291
291
|
Constructs a new priority queue initialized with the elements in the list
|
|
@@ -296,16 +296,16 @@ and a negative number if the first has less priority.
|
|
|
296
296
|
|
|
297
297
|
Parameters:
|
|
298
298
|
|
|
299
|
-
|param|type|description|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
| param | type | description |
|
|
300
|
+
| ---------- | ------------------ | --------------------------------------------------------- |
|
|
301
|
+
| `list` | `List<a>` | A list of values used to initialize the priority queue |
|
|
302
|
+
| `?compare` | `(a, a) => Number` | A comparator function used to assign priority to elements |
|
|
303
303
|
|
|
304
304
|
Returns:
|
|
305
305
|
|
|
306
|
-
|type|description|
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
| type | description |
|
|
307
|
+
| ------------------ | ------------------------------------------------------ |
|
|
308
|
+
| `PriorityQueue<a>` | A priority queue containing the elements from the list |
|
|
309
309
|
|
|
310
310
|
## PriorityQueue.Immutable
|
|
311
311
|
|
|
@@ -354,7 +354,7 @@ Functions and constants included in the PriorityQueue.Immutable module.
|
|
|
354
354
|
</details>
|
|
355
355
|
|
|
356
356
|
```grain
|
|
357
|
-
empty
|
|
357
|
+
empty: PriorityQueue<a>
|
|
358
358
|
```
|
|
359
359
|
|
|
360
360
|
An empty priority queue with the default `compare` comparator.
|
|
@@ -374,7 +374,7 @@ An empty priority queue with the default `compare` comparator.
|
|
|
374
374
|
</details>
|
|
375
375
|
|
|
376
376
|
```grain
|
|
377
|
-
make
|
|
377
|
+
make: (?compare: ((a, a) => Number)) => PriorityQueue<a>
|
|
378
378
|
```
|
|
379
379
|
|
|
380
380
|
Creates a new priority queue with a comparator function, which is used to
|
|
@@ -384,15 +384,15 @@ has greater priority, and a negative number if the first has less priority.
|
|
|
384
384
|
|
|
385
385
|
Parameters:
|
|
386
386
|
|
|
387
|
-
|param|type|description|
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
| param | type | description |
|
|
388
|
+
| ---------- | ------------------ | ------------------------------------------------------- |
|
|
389
|
+
| `?compare` | `(a, a) => Number` | The comparator function used to indicate priority order |
|
|
390
390
|
|
|
391
391
|
Returns:
|
|
392
392
|
|
|
393
|
-
|type|description|
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
| type | description |
|
|
394
|
+
| ------------------ | ----------------------- |
|
|
395
|
+
| `PriorityQueue<a>` | An empty priority queue |
|
|
396
396
|
|
|
397
397
|
Examples:
|
|
398
398
|
|
|
@@ -419,22 +419,22 @@ PriorityQueue.Immutable.make((a, b) => String.length(b) - String.length(a)) // c
|
|
|
419
419
|
</details>
|
|
420
420
|
|
|
421
421
|
```grain
|
|
422
|
-
size
|
|
422
|
+
size: (pq: PriorityQueue<a>) => Number
|
|
423
423
|
```
|
|
424
424
|
|
|
425
425
|
Gets the number of elements in a priority queue.
|
|
426
426
|
|
|
427
427
|
Parameters:
|
|
428
428
|
|
|
429
|
-
|param|type|description|
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
| param | type | description |
|
|
430
|
+
| ----- | ------------------ | ----------------------------- |
|
|
431
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to inspect |
|
|
432
432
|
|
|
433
433
|
Returns:
|
|
434
434
|
|
|
435
|
-
|type|description|
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
| type | description |
|
|
436
|
+
| -------- | -------------------------------------------- |
|
|
437
|
+
| `Number` | The number of elements in the priority queue |
|
|
438
438
|
|
|
439
439
|
#### PriorityQueue.Immutable.**isEmpty**
|
|
440
440
|
|
|
@@ -451,22 +451,22 @@ Returns:
|
|
|
451
451
|
</details>
|
|
452
452
|
|
|
453
453
|
```grain
|
|
454
|
-
isEmpty
|
|
454
|
+
isEmpty: (pq: PriorityQueue<a>) => Bool
|
|
455
455
|
```
|
|
456
456
|
|
|
457
457
|
Determines if the priority queue contains no elements.
|
|
458
458
|
|
|
459
459
|
Parameters:
|
|
460
460
|
|
|
461
|
-
|param|type|description|
|
|
462
|
-
|
|
463
|
-
|
|
461
|
+
| param | type | description |
|
|
462
|
+
| ----- | ------------------ | --------------------------- |
|
|
463
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to check |
|
|
464
464
|
|
|
465
465
|
Returns:
|
|
466
466
|
|
|
467
|
-
|type|description|
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
| type | description |
|
|
468
|
+
| ------ | ----------------------------------------------------------- |
|
|
469
|
+
| `Bool` | `true` if the priority queue is empty and `false` otherwise |
|
|
470
470
|
|
|
471
471
|
#### PriorityQueue.Immutable.**push**
|
|
472
472
|
|
|
@@ -483,23 +483,23 @@ Returns:
|
|
|
483
483
|
</details>
|
|
484
484
|
|
|
485
485
|
```grain
|
|
486
|
-
push
|
|
486
|
+
push: (val: a, pq: PriorityQueue<a>) => PriorityQueue<a>
|
|
487
487
|
```
|
|
488
488
|
|
|
489
489
|
Produces a new priority queue by inserting the given element into the given priority queue.
|
|
490
490
|
|
|
491
491
|
Parameters:
|
|
492
492
|
|
|
493
|
-
|param|type|description|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
| param | type | description |
|
|
494
|
+
| ----- | ------------------ | ---------------------------------------- |
|
|
495
|
+
| `val` | `a` | The value to add into the priority queue |
|
|
496
|
+
| `pq` | `PriorityQueue<a>` | The priority queue |
|
|
497
497
|
|
|
498
498
|
Returns:
|
|
499
499
|
|
|
500
|
-
|type|description|
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
| type | description |
|
|
501
|
+
| ------------------ | ---------------------------------------------------- |
|
|
502
|
+
| `PriorityQueue<a>` | A new priority queue with the given element inserted |
|
|
503
503
|
|
|
504
504
|
#### PriorityQueue.Immutable.**peek**
|
|
505
505
|
|
|
@@ -516,7 +516,7 @@ Returns:
|
|
|
516
516
|
</details>
|
|
517
517
|
|
|
518
518
|
```grain
|
|
519
|
-
peek
|
|
519
|
+
peek: (pq: PriorityQueue<a>) => Option<a>
|
|
520
520
|
```
|
|
521
521
|
|
|
522
522
|
Retrieves the highest priority element in the priority queue. It is not
|
|
@@ -524,15 +524,15 @@ removed from the queue.
|
|
|
524
524
|
|
|
525
525
|
Parameters:
|
|
526
526
|
|
|
527
|
-
|param|type|description|
|
|
528
|
-
|
|
529
|
-
|
|
527
|
+
| param | type | description |
|
|
528
|
+
| ----- | ------------------ | ----------------------------- |
|
|
529
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to inspect |
|
|
530
530
|
|
|
531
531
|
Returns:
|
|
532
532
|
|
|
533
|
-
|type|description|
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
| type | description |
|
|
534
|
+
| ----------- | ---------------------------------------------------------------------------------------------- |
|
|
535
|
+
| `Option<a>` | `Some(value)` containing the highest priority element or `None` if the priority queue is empty |
|
|
536
536
|
|
|
537
537
|
#### PriorityQueue.Immutable.**pop**
|
|
538
538
|
|
|
@@ -549,7 +549,7 @@ Returns:
|
|
|
549
549
|
</details>
|
|
550
550
|
|
|
551
551
|
```grain
|
|
552
|
-
pop
|
|
552
|
+
pop: (pq: PriorityQueue<a>) => PriorityQueue<a>
|
|
553
553
|
```
|
|
554
554
|
|
|
555
555
|
Produces a new priority queue without the highest priority element in the
|
|
@@ -558,15 +558,15 @@ return it.
|
|
|
558
558
|
|
|
559
559
|
Parameters:
|
|
560
560
|
|
|
561
|
-
|param|type|description|
|
|
562
|
-
|
|
563
|
-
|
|
561
|
+
| param | type | description |
|
|
562
|
+
| ----- | ------------------ | ------------------ |
|
|
563
|
+
| `pq` | `PriorityQueue<a>` | The priority queue |
|
|
564
564
|
|
|
565
565
|
Returns:
|
|
566
566
|
|
|
567
|
-
|type|description|
|
|
568
|
-
|
|
569
|
-
|
|
567
|
+
| type | description |
|
|
568
|
+
| ------------------ | --------------------------------------------------------- |
|
|
569
|
+
| `PriorityQueue<a>` | A new priority queue without the highest priority element |
|
|
570
570
|
|
|
571
571
|
#### PriorityQueue.Immutable.**drain**
|
|
572
572
|
|
|
@@ -583,22 +583,22 @@ Returns:
|
|
|
583
583
|
</details>
|
|
584
584
|
|
|
585
585
|
```grain
|
|
586
|
-
drain
|
|
586
|
+
drain: (pq: PriorityQueue<a>) => List<a>
|
|
587
587
|
```
|
|
588
588
|
|
|
589
589
|
Produces a list of all elements in the priority queue in priority order.
|
|
590
590
|
|
|
591
591
|
Parameters:
|
|
592
592
|
|
|
593
|
-
|param|type|description|
|
|
594
|
-
|
|
595
|
-
|
|
593
|
+
| param | type | description |
|
|
594
|
+
| ----- | ------------------ | --------------------------- |
|
|
595
|
+
| `pq` | `PriorityQueue<a>` | The priority queue to drain |
|
|
596
596
|
|
|
597
597
|
Returns:
|
|
598
598
|
|
|
599
|
-
|type|description|
|
|
600
|
-
|
|
601
|
-
|
|
599
|
+
| type | description |
|
|
600
|
+
| --------- | -------------------------------------------------------- |
|
|
601
|
+
| `List<a>` | A list of all elements in the priority in priority order |
|
|
602
602
|
|
|
603
603
|
#### PriorityQueue.Immutable.**fromList**
|
|
604
604
|
|
|
@@ -615,7 +615,7 @@ Returns:
|
|
|
615
615
|
</details>
|
|
616
616
|
|
|
617
617
|
```grain
|
|
618
|
-
fromList
|
|
618
|
+
fromList: (list: List<a>, ?compare: ((a, a) => Number)) => PriorityQueue<a>
|
|
619
619
|
```
|
|
620
620
|
|
|
621
621
|
Constructs a new priority queue initialized with the elements in the list
|
|
@@ -626,16 +626,16 @@ and a negative number if the first has less priority.
|
|
|
626
626
|
|
|
627
627
|
Parameters:
|
|
628
628
|
|
|
629
|
-
|param|type|description|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
629
|
+
| param | type | description |
|
|
630
|
+
| ---------- | ------------------ | --------------------------------------------------------- |
|
|
631
|
+
| `list` | `List<a>` | A list of values used to initialize the priority queue |
|
|
632
|
+
| `?compare` | `(a, a) => Number` | A comparator function used to assign priority to elements |
|
|
633
633
|
|
|
634
634
|
Returns:
|
|
635
635
|
|
|
636
|
-
|type|description|
|
|
637
|
-
|
|
638
|
-
|
|
636
|
+
| type | description |
|
|
637
|
+
| ------------------ | ------------------------------------------------------ |
|
|
638
|
+
| `PriorityQueue<a>` | A priority queue containing the elements from the list |
|
|
639
639
|
|
|
640
640
|
#### PriorityQueue.Immutable.**fromArray**
|
|
641
641
|
|
|
@@ -652,7 +652,7 @@ Returns:
|
|
|
652
652
|
</details>
|
|
653
653
|
|
|
654
654
|
```grain
|
|
655
|
-
fromArray
|
|
655
|
+
fromArray:
|
|
656
656
|
(array: Array<a>, ?compare: ((a, a) => Number)) => PriorityQueue<a>
|
|
657
657
|
```
|
|
658
658
|
|
|
@@ -664,14 +664,14 @@ and a negative number if the first has less priority.
|
|
|
664
664
|
|
|
665
665
|
Parameters:
|
|
666
666
|
|
|
667
|
-
|param|type|description|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
667
|
+
| param | type | description |
|
|
668
|
+
| ---------- | ------------------ | --------------------------------------------------------- |
|
|
669
|
+
| `array` | `Array<a>` | An array of values used to initialize the priority queue |
|
|
670
|
+
| `?compare` | `(a, a) => Number` | A comparator function used to assign priority to elements |
|
|
671
671
|
|
|
672
672
|
Returns:
|
|
673
673
|
|
|
674
|
-
|type|description|
|
|
675
|
-
|
|
676
|
-
|
|
674
|
+
| type | description |
|
|
675
|
+
| ------------------ | ------------------------------------------------------- |
|
|
676
|
+
| `PriorityQueue<a>` | A priority queue containing the elements from the array |
|
|
677
677
|
|