@mark1russell7/collections 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +78 -2
- package/build/dag/index.d.ts +144 -0
- package/build/dag/index.d.ts.map +1 -0
- package/build/dag/index.js +294 -0
- package/build/dag/index.js.map +1 -0
- package/build/graph/index.d.ts +20 -0
- package/build/graph/index.d.ts.map +1 -0
- package/build/graph/index.js +48 -0
- package/build/graph/index.js.map +1 -0
- package/build/index.d.ts +4952 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +7811 -0
- package/build/index.js.map +1 -0
- package/build/testing/index.d.ts +25 -0
- package/build/testing/index.d.ts.map +1 -0
- package/build/testing/index.js +72 -0
- package/build/testing/index.js.map +1 -0
- package/package.json +77 -3
- package/src/async/async-queue.ts +481 -0
- package/src/async/channels.ts +450 -0
- package/src/async/settled.ts +41 -0
- package/src/behaviors/bounded.ts +485 -0
- package/src/behaviors/composite.ts +99 -0
- package/src/behaviors/evented.ts +464 -0
- package/src/behaviors/lru.ts +449 -0
- package/src/behaviors/readonly.ts +236 -0
- package/src/behaviors/safe.ts +358 -0
- package/src/behaviors/synchronized.ts +316 -0
- package/src/behaviors/ttl.ts +464 -0
- package/src/core/effects.ts +327 -0
- package/src/core/events.ts +363 -0
- package/src/core/middleware.ts +413 -0
- package/src/core/policies.ts +316 -0
- package/src/core/traits.ts +164 -0
- package/src/dag/builder.ts +124 -0
- package/src/dag/executor.ts +190 -0
- package/src/dag/index.ts +14 -0
- package/src/dag/traversal.ts +129 -0
- package/src/dag/types.ts +87 -0
- package/src/fx/collectors.ts +500 -0
- package/src/fx/iter.ts +536 -0
- package/src/graph/hub-order.ts +53 -0
- package/src/graph/index.ts +5 -0
- package/src/impl/array-deque.ts +463 -0
- package/src/impl/array-list.ts +490 -0
- package/src/impl/hash-map.ts +623 -0
- package/src/impl/hash-set.ts +342 -0
- package/src/impl/linked-hash-map.ts +572 -0
- package/src/impl/linked-list.ts +610 -0
- package/src/impl/priority-queue.ts +448 -0
- package/src/impl/summary-tree.ts +594 -0
- package/src/impl/tree-map.ts +913 -0
- package/src/impl/tree-set.ts +469 -0
- package/src/index.ts +237 -0
- package/src/interfaces/collection.ts +141 -0
- package/src/interfaces/list.ts +281 -0
- package/src/interfaces/map.ts +405 -0
- package/src/interfaces/queue.ts +353 -0
- package/src/interfaces/set.ts +158 -0
- package/src/order/index.ts +6 -0
- package/src/order/rank.ts +271 -0
- package/src/storage/listeners.ts +72 -0
- package/src/testing/check.ts +81 -0
- package/src/testing/index.ts +7 -0
- package/src/utils/defaults.ts +345 -0
- package/src/utils/factories.ts +357 -0
- package/src/utils/helpers.ts +248 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue and Deque interfaces that mirror Java's Queue and Deque.
|
|
3
|
+
*
|
|
4
|
+
* Queues are collections that hold elements before processing.
|
|
5
|
+
* Deques (double-ended queues) give efficient insertion/removal at both ends.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Collection, ReadonlyCollection } from "./collection.js";
|
|
9
|
+
import type { Compare } from "../core/traits.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ReadonlyQueue<T> - Readonly FIFO (First-In-First-Out) queue.
|
|
13
|
+
*
|
|
14
|
+
* This type gives read-only access to queue operations.
|
|
15
|
+
*/
|
|
16
|
+
export interface ReadonlyQueue<T> extends ReadonlyCollection<T> {
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves, but does not remove, the head of this queue.
|
|
19
|
+
*
|
|
20
|
+
* @returns The head element
|
|
21
|
+
* @throws Error if queue is empty
|
|
22
|
+
*/
|
|
23
|
+
peek(): T;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This method gives the head element without throwing if empty.
|
|
27
|
+
* This method gives undefined if queue is empty.
|
|
28
|
+
*/
|
|
29
|
+
peekOrUndefined(): T | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Queue<T> - FIFO (First-In-First-Out) queue.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors java.util.Queue.
|
|
36
|
+
* Elements are processed in the order they were added.
|
|
37
|
+
*/
|
|
38
|
+
export interface Queue<T> extends ReadonlyQueue<T>, Collection<T> {
|
|
39
|
+
/**
|
|
40
|
+
* This method inserts an element into the queue.
|
|
41
|
+
* For bounded queues with overflow='throw', throws if queue is full.
|
|
42
|
+
*
|
|
43
|
+
* @param element The element to add
|
|
44
|
+
* @returns true if element was added
|
|
45
|
+
* @throws Error if queue is full (bounded with throw policy)
|
|
46
|
+
*/
|
|
47
|
+
offer(element: T): boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves and removes the head of this queue.
|
|
51
|
+
*
|
|
52
|
+
* @returns The head element
|
|
53
|
+
* @throws Error if queue is empty
|
|
54
|
+
*/
|
|
55
|
+
poll(): T;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves and removes the head of this queue, or gives undefined if empty.
|
|
59
|
+
*/
|
|
60
|
+
pollOrUndefined(): T | undefined;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Alias for offer(). This method adds element to end of queue.
|
|
64
|
+
* This method is here for consistency with standard queue terminology.
|
|
65
|
+
*/
|
|
66
|
+
enqueue(element: T): boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Alias for poll(). Removes and gives element from front of queue.
|
|
70
|
+
* This method is here for consistency with standard queue terminology.
|
|
71
|
+
*/
|
|
72
|
+
dequeue(): T;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Deque<T> - Double-ended queue.
|
|
77
|
+
*
|
|
78
|
+
* Mirrors java.util.Deque.
|
|
79
|
+
* This type supports insertion and removal at both ends.
|
|
80
|
+
* This type operates as a queue (FIFO) or a stack (LIFO).
|
|
81
|
+
*/
|
|
82
|
+
export interface Deque<T> extends Queue<T> {
|
|
83
|
+
// First element operations (head of queue)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* This method inserts element at the front of this deque.
|
|
87
|
+
*
|
|
88
|
+
* @param element The element to add
|
|
89
|
+
* @throws Error if deque is full (bounded with throw policy)
|
|
90
|
+
*/
|
|
91
|
+
addFirst(element: T): void;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* This method inserts element at the front, giving false if full.
|
|
95
|
+
*/
|
|
96
|
+
offerFirst(element: T): boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves and removes the first element.
|
|
100
|
+
*
|
|
101
|
+
* @throws Error if deque is empty
|
|
102
|
+
*/
|
|
103
|
+
removeFirst(): T;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves and removes the first element, or undefined if empty.
|
|
107
|
+
*/
|
|
108
|
+
pollFirst(): T | undefined;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Retrieves but does not remove the first element.
|
|
112
|
+
*
|
|
113
|
+
* @throws Error if deque is empty
|
|
114
|
+
*/
|
|
115
|
+
peekFirst(): T;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves but does not remove the first element, or undefined if empty.
|
|
119
|
+
*/
|
|
120
|
+
peekFirstOrUndefined(): T | undefined;
|
|
121
|
+
|
|
122
|
+
// Last element operations (tail of queue)
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This method inserts element at the end of this deque.
|
|
126
|
+
*
|
|
127
|
+
* @param element The element to add
|
|
128
|
+
* @throws Error if deque is full (bounded with throw policy)
|
|
129
|
+
*/
|
|
130
|
+
addLast(element: T): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* This method inserts element at the end, giving false if full.
|
|
134
|
+
*/
|
|
135
|
+
offerLast(element: T): boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Retrieves and removes the last element.
|
|
139
|
+
*
|
|
140
|
+
* @throws Error if deque is empty
|
|
141
|
+
*/
|
|
142
|
+
removeLast(): T;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves and removes the last element, or undefined if empty.
|
|
146
|
+
*/
|
|
147
|
+
pollLast(): T | undefined;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves but does not remove the last element.
|
|
151
|
+
*
|
|
152
|
+
* @throws Error if deque is empty
|
|
153
|
+
*/
|
|
154
|
+
peekLast(): T;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves but does not remove the last element, or undefined if empty.
|
|
158
|
+
*/
|
|
159
|
+
peekLastOrUndefined(): T | undefined;
|
|
160
|
+
|
|
161
|
+
// Stack operations (LIFO). As on a JavaScript array and on every List of this package,
|
|
162
|
+
// push and pop work at the end. (Java's Deque uses the front.) The top of the stack is peekLast().
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* This method pushes element onto the stack represented by this deque.
|
|
166
|
+
* Equivalent to addLast().
|
|
167
|
+
*
|
|
168
|
+
* @param element The element to push
|
|
169
|
+
*/
|
|
170
|
+
push(element: T): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* This method pops an element from the stack represented by this deque.
|
|
174
|
+
* Equivalent to removeLast().
|
|
175
|
+
*
|
|
176
|
+
* @returns The popped element
|
|
177
|
+
* @throws Error if deque is empty
|
|
178
|
+
*/
|
|
179
|
+
pop(): T;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* BlockingQueue<T> - Queue that supports blocking operations.
|
|
184
|
+
*
|
|
185
|
+
* Mirrors java.util.concurrent.BlockingQueue.
|
|
186
|
+
* Useful for producer-consumer patterns.
|
|
187
|
+
*/
|
|
188
|
+
export interface BlockingQueue<T> extends Queue<T> {
|
|
189
|
+
/**
|
|
190
|
+
* This method inserts element, waiting if necessary for space to become available.
|
|
191
|
+
*
|
|
192
|
+
* @param element The element to add
|
|
193
|
+
* @param timeoutMs Optional timeout in milliseconds
|
|
194
|
+
* @returns Promise that resolves to true when element is added
|
|
195
|
+
* @throws Error if timeout expires
|
|
196
|
+
*/
|
|
197
|
+
put(element: T, timeoutMs?: number): Promise<void>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Retrieves and removes the head, waiting if necessary until an element is available.
|
|
201
|
+
*
|
|
202
|
+
* @param timeoutMs Optional timeout in milliseconds
|
|
203
|
+
* @returns Promise that resolves to the head element
|
|
204
|
+
* @throws Error if timeout expires
|
|
205
|
+
*/
|
|
206
|
+
take(timeoutMs?: number): Promise<T>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* This value is the remaining capacity.
|
|
210
|
+
* This value is Infinity for unbounded queues.
|
|
211
|
+
*/
|
|
212
|
+
readonly remainingCapacity: number;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* This method removes all available elements and adds them to the given array.
|
|
216
|
+
* This method gives the number of elements transferred.
|
|
217
|
+
*/
|
|
218
|
+
drainTo(target: T[], maxElements?: number): number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* PriorityQueue<T> - Queue that orders elements by priority.
|
|
223
|
+
*
|
|
224
|
+
* Mirrors java.util.PriorityQueue.
|
|
225
|
+
* Elements are removed in priority order (not insertion order).
|
|
226
|
+
* A comparison function is necessary for this type to determine priority.
|
|
227
|
+
*/
|
|
228
|
+
export interface PriorityQueue<T> extends Queue<T> {
|
|
229
|
+
/**
|
|
230
|
+
* The comparison function used to determine priority.
|
|
231
|
+
* Elements with lower compare value have higher priority.
|
|
232
|
+
*/
|
|
233
|
+
readonly compare: Compare<T>;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* This value is the comparator used to order elements, or undefined if natural ordering.
|
|
237
|
+
*/
|
|
238
|
+
readonly comparator: Compare<T> | undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* AsyncQueue<T> - Async iterable queue.
|
|
243
|
+
*
|
|
244
|
+
* This type is for async/await patterns and streaming data.
|
|
245
|
+
* This type implements AsyncIterable for use with for-await-of loops.
|
|
246
|
+
*/
|
|
247
|
+
export interface AsyncQueue<T> extends AsyncIterable<T> {
|
|
248
|
+
/** This value is the number of elements in the queue. */
|
|
249
|
+
readonly size: number;
|
|
250
|
+
|
|
251
|
+
/** True if queue is empty */
|
|
252
|
+
readonly isEmpty: boolean;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* This method adds element to queue.
|
|
256
|
+
* For bounded queues, this method can wait for space to become available.
|
|
257
|
+
*/
|
|
258
|
+
put(element: T): Promise<void>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Removes and gives next element.
|
|
262
|
+
* Waits for an element if queue is empty.
|
|
263
|
+
*/
|
|
264
|
+
take(): Promise<T>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* This method tries to add element without waiting.
|
|
268
|
+
* This method gives false if queue is full.
|
|
269
|
+
*/
|
|
270
|
+
tryPut(element: T): boolean;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* This method tries to remove element without waiting.
|
|
274
|
+
* This method gives undefined if queue is empty.
|
|
275
|
+
*/
|
|
276
|
+
tryTake(): T | undefined;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* This method gives next element without removing it.
|
|
280
|
+
* Waits for an element if queue is empty.
|
|
281
|
+
*/
|
|
282
|
+
peek(): Promise<T>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* This method closes the queue, preventing further additions.
|
|
286
|
+
* After this method, consumers can still take the existing elements.
|
|
287
|
+
*/
|
|
288
|
+
close(): void;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* This value is true if queue is closed.
|
|
292
|
+
*/
|
|
293
|
+
readonly isClosed: boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* TransferQueue<T> - Queue where producers can wait for consumers.
|
|
298
|
+
*
|
|
299
|
+
* Mirrors java.util.concurrent.TransferQueue.
|
|
300
|
+
* Useful for direct handoff between producer and consumer threads.
|
|
301
|
+
*/
|
|
302
|
+
export interface TransferQueue<T> extends BlockingQueue<T> {
|
|
303
|
+
/**
|
|
304
|
+
* Transfers element to consumer, waiting if necessary.
|
|
305
|
+
* This method waits for a consumer to receive the element.
|
|
306
|
+
*
|
|
307
|
+
* @param element The element to transfer
|
|
308
|
+
* @returns Promise that resolves when element is received
|
|
309
|
+
*/
|
|
310
|
+
transfer(element: T): Promise<void>;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* This method tries to transfer element to waiting consumer.
|
|
314
|
+
* This method gives false immediately if no consumer is waiting.
|
|
315
|
+
*
|
|
316
|
+
* @param element The element to transfer
|
|
317
|
+
* @param timeoutMs Optional timeout in milliseconds
|
|
318
|
+
*/
|
|
319
|
+
tryTransfer(element: T, timeoutMs?: number): Promise<boolean>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* This value is true if there are consumers waiting to receive elements.
|
|
323
|
+
*/
|
|
324
|
+
readonly hasWaitingConsumer: boolean;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* This value is an estimate of the number of consumers waiting to receive elements.
|
|
328
|
+
*/
|
|
329
|
+
readonly waitingConsumerCount: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* DelayQueue<T> - Queue where elements become available after a delay.
|
|
334
|
+
*
|
|
335
|
+
* Mirrors java.util.concurrent.DelayQueue.
|
|
336
|
+
* Elements can only be removed once their delay has expired.
|
|
337
|
+
*/
|
|
338
|
+
export interface DelayQueue<T> extends BlockingQueue<T> {
|
|
339
|
+
/**
|
|
340
|
+
* This method adds element with specified delay.
|
|
341
|
+
*
|
|
342
|
+
* @param element The element to add
|
|
343
|
+
* @param delayMs Delay in milliseconds before element becomes available (defaults to 0)
|
|
344
|
+
*/
|
|
345
|
+
offer(element: T, delayMs?: number): boolean;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* This value is the delay (in ms) until next element becomes available.
|
|
349
|
+
* The delay is `0` when the element is available.
|
|
350
|
+
* This value is Infinity if queue is empty.
|
|
351
|
+
*/
|
|
352
|
+
readonly nextDelay: number;
|
|
353
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set interfaces that mirror Java's Set interface hierarchy.
|
|
3
|
+
*
|
|
4
|
+
* Sets are collections that contain no duplicate elements.
|
|
5
|
+
* They give efficient membership testing.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Collection, ReadonlyCollection } from "./collection.js";
|
|
9
|
+
import type { Compare } from "../core/traits.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ReadonlySet<T> - Readonly set with no duplicates.
|
|
13
|
+
*/
|
|
14
|
+
export interface ReadonlySet<T> extends ReadonlyCollection<T> {
|
|
15
|
+
/**
|
|
16
|
+
* This method gives true if this set contains the specified element.
|
|
17
|
+
*/
|
|
18
|
+
contains(element: T): boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This method gives true if this set contains all elements in the specified collection.
|
|
22
|
+
*/
|
|
23
|
+
containsAll(other: Iterable<T>): boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Set<T> - Mutable set with no duplicates.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors java.util.Set.
|
|
30
|
+
* Elements are unique based on the set's equality function.
|
|
31
|
+
*/
|
|
32
|
+
export interface Set<T> extends ReadonlySet<T>, Collection<T> {
|
|
33
|
+
/**
|
|
34
|
+
* This method adds the specified element to this set if it is not already present.
|
|
35
|
+
*
|
|
36
|
+
* @returns true if this set did not already contain the element
|
|
37
|
+
*/
|
|
38
|
+
add(element: T): boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This method removes the specified element from this set if it is present.
|
|
42
|
+
*
|
|
43
|
+
* @returns true if this set contained the element
|
|
44
|
+
*/
|
|
45
|
+
remove(element: T): boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This method adds all elements in the specified collection to this set.
|
|
49
|
+
* This is a union operation.
|
|
50
|
+
*
|
|
51
|
+
* @returns true if this set changed
|
|
52
|
+
*/
|
|
53
|
+
addAll(other: Iterable<T>): boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This method removes from this set all of its elements that are contained in the specified collection.
|
|
57
|
+
* This is a difference operation.
|
|
58
|
+
*
|
|
59
|
+
* @returns true if this set changed
|
|
60
|
+
*/
|
|
61
|
+
removeAll(other: Iterable<T>): boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This method retains only the elements in this set that are contained in the specified collection.
|
|
65
|
+
* This is an intersection operation.
|
|
66
|
+
*
|
|
67
|
+
* @returns true if this set changed
|
|
68
|
+
*/
|
|
69
|
+
retainAll(other: Iterable<T>): boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* SortedSet<T> - Set that maintains elements in sorted order.
|
|
74
|
+
*
|
|
75
|
+
* Mirrors java.util.SortedSet.
|
|
76
|
+
*/
|
|
77
|
+
export interface SortedSet<T> extends Set<T> {
|
|
78
|
+
/**
|
|
79
|
+
* This value is the comparator used to order elements in this set.
|
|
80
|
+
*/
|
|
81
|
+
readonly comparator: Compare<T>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* This method gives the first (lowest) element in this set.
|
|
85
|
+
*
|
|
86
|
+
* @throws Error if set is empty
|
|
87
|
+
*/
|
|
88
|
+
first(): T;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* This method gives the last (highest) element in this set.
|
|
92
|
+
*
|
|
93
|
+
* @throws Error if set is empty
|
|
94
|
+
*/
|
|
95
|
+
last(): T;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* This method gives a view of the portion of this set whose elements are strictly less than toElement.
|
|
99
|
+
*/
|
|
100
|
+
headSet(toElement: T): SortedSet<T>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* This method gives a view of the portion of this set whose elements are greater than or equal to fromElement.
|
|
104
|
+
*/
|
|
105
|
+
tailSet(fromElement: T): SortedSet<T>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* This method gives a view of the portion of this set whose elements range from fromElement to toElement.
|
|
109
|
+
*/
|
|
110
|
+
subSet(fromElement: T, toElement: T): SortedSet<T>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* NavigableSet<T> - Extended sorted set with navigation methods.
|
|
115
|
+
*
|
|
116
|
+
* Mirrors java.util.NavigableSet.
|
|
117
|
+
*/
|
|
118
|
+
export interface NavigableSet<T> extends SortedSet<T> {
|
|
119
|
+
/**
|
|
120
|
+
* This method gives the greatest element less than or equal to the given element, or undefined if none.
|
|
121
|
+
*/
|
|
122
|
+
floor(element: T): T | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This method gives the least element greater than or equal to the given element, or undefined if none.
|
|
126
|
+
*/
|
|
127
|
+
ceiling(element: T): T | undefined;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* This method gives the greatest element strictly less than the given element, or undefined if none.
|
|
131
|
+
*/
|
|
132
|
+
lower(element: T): T | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* This method gives the least element strictly greater than the given element, or undefined if none.
|
|
136
|
+
*/
|
|
137
|
+
higher(element: T): T | undefined;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Retrieves and removes the first (lowest) element, or gives undefined if empty.
|
|
141
|
+
*/
|
|
142
|
+
pollFirst(): T | undefined;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves and removes the last (highest) element, or gives undefined if empty.
|
|
146
|
+
*/
|
|
147
|
+
pollLast(): T | undefined;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* This method gives a reverse order view of this set.
|
|
151
|
+
*/
|
|
152
|
+
descendingSet(): NavigableSet<T>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* This method gives a reverse order iterator over the elements in this set.
|
|
156
|
+
*/
|
|
157
|
+
descendingIterator(): Iterator<T>;
|
|
158
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order of a list as data. Each item keeps a string key, and the list
|
|
3
|
+
* sorts by it. An item that moves between two others gets a key between theirs, so a move writes one
|
|
4
|
+
* item and no other.
|
|
5
|
+
*/
|
|
6
|
+
export { KEY_DIGITS, keyBetween, keysBetween, keysForDrop, compareKeys, isValidKey, dropIndex, type KeyCheckOptions, type KeyedItem, type Point } from "./rank.js";
|