@procedures/collections 0.46.0 → 0.47.2

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.
Files changed (233) hide show
  1. package/CHANGELOG.md +42 -8
  2. package/README.md +30 -0
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/index.d.ts +1 -58
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -94
  7. package/dist/index.js.map +1 -1
  8. package/dist/storage/index.d.ts +2 -2
  9. package/dist/storage/index.d.ts.map +1 -1
  10. package/dist/storage/index.js +1 -1
  11. package/dist/storage/index.js.map +1 -1
  12. package/dist/storage/memory.d.ts +1 -1
  13. package/dist/storage/memory.d.ts.map +1 -1
  14. package/dist/storage/memory.js +1 -1
  15. package/dist/storage/memory.js.map +1 -1
  16. package/dist/testing/index.d.ts +1 -1
  17. package/dist/testing/index.d.ts.map +1 -1
  18. package/dist/testing/index.js +1 -1
  19. package/dist/testing/index.js.map +1 -1
  20. package/dist/testing/storage-contract.js +1 -1
  21. package/dist/testing/storage-contract.js.map +1 -1
  22. package/dist/undo/index.d.ts +1 -1
  23. package/dist/undo/index.js +1 -1
  24. package/dist/undo/undo-log.d.ts +1 -1
  25. package/dist/undo/undo-log.js +1 -1
  26. package/package.json +6 -6
  27. package/src/index.ts +338 -213
  28. package/src/storage/index.ts +2 -2
  29. package/src/storage/memory.ts +1 -1
  30. package/src/testing/index.ts +1 -1
  31. package/src/testing/storage-contract.ts +1 -1
  32. package/src/undo/index.ts +1 -1
  33. package/src/undo/undo-log.ts +1 -1
  34. package/dist/async/async-queue.d.ts +0 -170
  35. package/dist/async/async-queue.d.ts.map +0 -1
  36. package/dist/async/async-queue.js +0 -404
  37. package/dist/async/async-queue.js.map +0 -1
  38. package/dist/async/channels.d.ts +0 -211
  39. package/dist/async/channels.d.ts.map +0 -1
  40. package/dist/async/channels.js +0 -393
  41. package/dist/async/channels.js.map +0 -1
  42. package/dist/async/settled.d.ts +0 -23
  43. package/dist/async/settled.d.ts.map +0 -1
  44. package/dist/async/settled.js +0 -32
  45. package/dist/async/settled.js.map +0 -1
  46. package/dist/behaviors/bounded.d.ts +0 -79
  47. package/dist/behaviors/bounded.d.ts.map +0 -1
  48. package/dist/behaviors/bounded.js +0 -393
  49. package/dist/behaviors/bounded.js.map +0 -1
  50. package/dist/behaviors/composite.d.ts +0 -17
  51. package/dist/behaviors/composite.d.ts.map +0 -1
  52. package/dist/behaviors/composite.js +0 -93
  53. package/dist/behaviors/composite.js.map +0 -1
  54. package/dist/behaviors/evented.d.ts +0 -154
  55. package/dist/behaviors/evented.d.ts.map +0 -1
  56. package/dist/behaviors/evented.js +0 -299
  57. package/dist/behaviors/evented.js.map +0 -1
  58. package/dist/behaviors/lru.d.ts +0 -84
  59. package/dist/behaviors/lru.d.ts.map +0 -1
  60. package/dist/behaviors/lru.js +0 -376
  61. package/dist/behaviors/lru.js.map +0 -1
  62. package/dist/behaviors/readonly.d.ts +0 -73
  63. package/dist/behaviors/readonly.d.ts.map +0 -1
  64. package/dist/behaviors/readonly.js +0 -189
  65. package/dist/behaviors/readonly.js.map +0 -1
  66. package/dist/behaviors/safe.d.ts +0 -163
  67. package/dist/behaviors/safe.d.ts.map +0 -1
  68. package/dist/behaviors/safe.js +0 -176
  69. package/dist/behaviors/safe.js.map +0 -1
  70. package/dist/behaviors/synchronized.d.ts +0 -88
  71. package/dist/behaviors/synchronized.d.ts.map +0 -1
  72. package/dist/behaviors/synchronized.js +0 -285
  73. package/dist/behaviors/synchronized.js.map +0 -1
  74. package/dist/behaviors/ttl.d.ts +0 -118
  75. package/dist/behaviors/ttl.d.ts.map +0 -1
  76. package/dist/behaviors/ttl.js +0 -354
  77. package/dist/behaviors/ttl.js.map +0 -1
  78. package/dist/contracts/model.d.ts +0 -29
  79. package/dist/contracts/model.d.ts.map +0 -1
  80. package/dist/contracts/model.js +0 -26
  81. package/dist/contracts/model.js.map +0 -1
  82. package/dist/core/effects.d.ts +0 -176
  83. package/dist/core/effects.d.ts.map +0 -1
  84. package/dist/core/effects.js +0 -180
  85. package/dist/core/effects.js.map +0 -1
  86. package/dist/core/events.d.ts +0 -192
  87. package/dist/core/events.d.ts.map +0 -1
  88. package/dist/core/events.js +0 -291
  89. package/dist/core/events.js.map +0 -1
  90. package/dist/core/middleware.d.ts +0 -231
  91. package/dist/core/middleware.d.ts.map +0 -1
  92. package/dist/core/middleware.js +0 -161
  93. package/dist/core/middleware.js.map +0 -1
  94. package/dist/core/policies.d.ts +0 -220
  95. package/dist/core/policies.d.ts.map +0 -1
  96. package/dist/core/policies.js +0 -48
  97. package/dist/core/policies.js.map +0 -1
  98. package/dist/core/traits.d.ts +0 -142
  99. package/dist/core/traits.d.ts.map +0 -1
  100. package/dist/core/traits.js +0 -8
  101. package/dist/core/traits.js.map +0 -1
  102. package/dist/fx/collectors.d.ts +0 -193
  103. package/dist/fx/collectors.d.ts.map +0 -1
  104. package/dist/fx/collectors.js +0 -375
  105. package/dist/fx/collectors.js.map +0 -1
  106. package/dist/fx/iter.d.ts +0 -166
  107. package/dist/fx/iter.d.ts.map +0 -1
  108. package/dist/fx/iter.js +0 -421
  109. package/dist/fx/iter.js.map +0 -1
  110. package/dist/impl/array-deque.d.ts +0 -112
  111. package/dist/impl/array-deque.d.ts.map +0 -1
  112. package/dist/impl/array-deque.js +0 -380
  113. package/dist/impl/array-deque.js.map +0 -1
  114. package/dist/impl/array-list.d.ts +0 -101
  115. package/dist/impl/array-list.d.ts.map +0 -1
  116. package/dist/impl/array-list.js +0 -387
  117. package/dist/impl/array-list.js.map +0 -1
  118. package/dist/impl/hash-map.d.ts +0 -149
  119. package/dist/impl/hash-map.d.ts.map +0 -1
  120. package/dist/impl/hash-map.js +0 -473
  121. package/dist/impl/hash-map.js.map +0 -1
  122. package/dist/impl/hash-set.d.ts +0 -125
  123. package/dist/impl/hash-set.d.ts.map +0 -1
  124. package/dist/impl/hash-set.js +0 -264
  125. package/dist/impl/hash-set.js.map +0 -1
  126. package/dist/impl/linked-hash-map.d.ts +0 -141
  127. package/dist/impl/linked-hash-map.d.ts.map +0 -1
  128. package/dist/impl/linked-hash-map.js +0 -442
  129. package/dist/impl/linked-hash-map.js.map +0 -1
  130. package/dist/impl/linked-list.d.ts +0 -109
  131. package/dist/impl/linked-list.d.ts.map +0 -1
  132. package/dist/impl/linked-list.js +0 -494
  133. package/dist/impl/linked-list.js.map +0 -1
  134. package/dist/impl/priority-queue.d.ts +0 -139
  135. package/dist/impl/priority-queue.d.ts.map +0 -1
  136. package/dist/impl/priority-queue.js +0 -343
  137. package/dist/impl/priority-queue.js.map +0 -1
  138. package/dist/impl/tree-map.d.ts +0 -153
  139. package/dist/impl/tree-map.d.ts.map +0 -1
  140. package/dist/impl/tree-map.js +0 -788
  141. package/dist/impl/tree-map.js.map +0 -1
  142. package/dist/impl/tree-set.d.ts +0 -112
  143. package/dist/impl/tree-set.d.ts.map +0 -1
  144. package/dist/impl/tree-set.js +0 -374
  145. package/dist/impl/tree-set.js.map +0 -1
  146. package/dist/interfaces/collection.d.ts +0 -119
  147. package/dist/interfaces/collection.d.ts.map +0 -1
  148. package/dist/interfaces/collection.js +0 -8
  149. package/dist/interfaces/collection.js.map +0 -1
  150. package/dist/interfaces/list.d.ts +0 -247
  151. package/dist/interfaces/list.d.ts.map +0 -1
  152. package/dist/interfaces/list.js +0 -8
  153. package/dist/interfaces/list.js.map +0 -1
  154. package/dist/interfaces/map.d.ts +0 -344
  155. package/dist/interfaces/map.d.ts.map +0 -1
  156. package/dist/interfaces/map.js +0 -8
  157. package/dist/interfaces/map.js.map +0 -1
  158. package/dist/interfaces/queue.d.ts +0 -304
  159. package/dist/interfaces/queue.d.ts.map +0 -1
  160. package/dist/interfaces/queue.js +0 -8
  161. package/dist/interfaces/queue.js.map +0 -1
  162. package/dist/interfaces/set.d.ts +0 -137
  163. package/dist/interfaces/set.d.ts.map +0 -1
  164. package/dist/interfaces/set.js +0 -8
  165. package/dist/interfaces/set.js.map +0 -1
  166. package/dist/order/index.d.ts +0 -7
  167. package/dist/order/index.d.ts.map +0 -1
  168. package/dist/order/index.js +0 -7
  169. package/dist/order/index.js.map +0 -1
  170. package/dist/order/rank.d.ts +0 -100
  171. package/dist/order/rank.d.ts.map +0 -1
  172. package/dist/order/rank.js +0 -286
  173. package/dist/order/rank.js.map +0 -1
  174. package/dist/storage/listeners.d.ts +0 -39
  175. package/dist/storage/listeners.d.ts.map +0 -1
  176. package/dist/storage/listeners.js +0 -65
  177. package/dist/storage/listeners.js.map +0 -1
  178. package/dist/testing/check.d.ts +0 -25
  179. package/dist/testing/check.d.ts.map +0 -1
  180. package/dist/testing/check.js +0 -85
  181. package/dist/testing/check.js.map +0 -1
  182. package/dist/utils/defaults.d.ts +0 -135
  183. package/dist/utils/defaults.d.ts.map +0 -1
  184. package/dist/utils/defaults.js +0 -322
  185. package/dist/utils/defaults.js.map +0 -1
  186. package/dist/utils/factories.d.ts +0 -144
  187. package/dist/utils/factories.d.ts.map +0 -1
  188. package/dist/utils/factories.js +0 -293
  189. package/dist/utils/factories.js.map +0 -1
  190. package/dist/utils/helpers.d.ts +0 -137
  191. package/dist/utils/helpers.d.ts.map +0 -1
  192. package/dist/utils/helpers.js +0 -221
  193. package/dist/utils/helpers.js.map +0 -1
  194. package/src/async/async-queue.ts +0 -481
  195. package/src/async/channels.ts +0 -450
  196. package/src/async/settled.ts +0 -41
  197. package/src/behaviors/bounded.ts +0 -485
  198. package/src/behaviors/composite.ts +0 -99
  199. package/src/behaviors/evented.ts +0 -464
  200. package/src/behaviors/lru.ts +0 -447
  201. package/src/behaviors/readonly.ts +0 -236
  202. package/src/behaviors/safe.ts +0 -372
  203. package/src/behaviors/synchronized.ts +0 -316
  204. package/src/behaviors/ttl.ts +0 -462
  205. package/src/contracts/model.ts +0 -44
  206. package/src/core/effects.ts +0 -323
  207. package/src/core/events.ts +0 -356
  208. package/src/core/middleware.ts +0 -415
  209. package/src/core/policies.ts +0 -316
  210. package/src/core/traits.ts +0 -164
  211. package/src/fx/collectors.ts +0 -500
  212. package/src/fx/iter.ts +0 -536
  213. package/src/impl/array-deque.ts +0 -463
  214. package/src/impl/array-list.ts +0 -490
  215. package/src/impl/hash-map.ts +0 -623
  216. package/src/impl/hash-set.ts +0 -342
  217. package/src/impl/linked-hash-map.ts +0 -572
  218. package/src/impl/linked-list.ts +0 -606
  219. package/src/impl/priority-queue.ts +0 -448
  220. package/src/impl/tree-map.ts +0 -912
  221. package/src/impl/tree-set.ts +0 -469
  222. package/src/interfaces/collection.ts +0 -141
  223. package/src/interfaces/list.ts +0 -281
  224. package/src/interfaces/map.ts +0 -405
  225. package/src/interfaces/queue.ts +0 -353
  226. package/src/interfaces/set.ts +0 -158
  227. package/src/order/index.ts +0 -6
  228. package/src/order/rank.ts +0 -271
  229. package/src/storage/listeners.ts +0 -72
  230. package/src/testing/check.ts +0 -81
  231. package/src/utils/defaults.ts +0 -345
  232. package/src/utils/factories.ts +0 -357
  233. package/src/utils/helpers.ts +0 -248
@@ -1,353 +0,0 @@
1
- /**
2
- * Queue and Deque interfaces that mirror Java's Queue and Deque.
3
- *
4
- * Queues are collections designed for holding elements prior to processing.
5
- * Deques (double-ended queues) allow 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
- * Provides 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
- * Returns the head element without throwing if empty.
27
- * Returns 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
- * 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 returns undefined if empty.
59
- */
60
- pollOrUndefined(): T | undefined;
61
-
62
- /**
63
- * Alias for offer(). Adds element to end of queue.
64
- * Included for consistency with standard queue terminology.
65
- */
66
- enqueue(element: T): boolean;
67
-
68
- /**
69
- * Alias for poll(). Removes and returns element from front of queue.
70
- * Included 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
- * Supports insertion and removal at both ends.
80
- * Can be used as a queue (FIFO) or stack (LIFO).
81
- */
82
- export interface Deque<T> extends Queue<T> {
83
- // First element operations (head of queue)
84
-
85
- /**
86
- * 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
- * Inserts element at the front, returning 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
- * 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
- * Inserts element at the end, returning 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
- * 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
- * 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
- * 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
- * Returns the remaining capacity.
210
- * Returns Infinity for unbounded queues.
211
- */
212
- readonly remainingCapacity: number;
213
-
214
- /**
215
- * Removes all available elements and adds them to the given array.
216
- * Returns 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
- * Requires a comparison function 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
- * Returns 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
- * Designed for async/await patterns and streaming data.
245
- * Implements AsyncIterable for use with for-await-of loops.
246
- */
247
- export interface AsyncQueue<T> extends AsyncIterable<T> {
248
- /** Number of elements currently in queue */
249
- readonly size: number;
250
-
251
- /** True if queue is empty */
252
- readonly isEmpty: boolean;
253
-
254
- /**
255
- * Adds element to queue.
256
- * For bounded queues, may wait for space to become available.
257
- */
258
- put(element: T): Promise<void>;
259
-
260
- /**
261
- * Removes and returns next element.
262
- * Waits for an element if queue is empty.
263
- */
264
- take(): Promise<T>;
265
-
266
- /**
267
- * Attempts to add element without waiting.
268
- * Returns false if queue is full.
269
- */
270
- tryPut(element: T): boolean;
271
-
272
- /**
273
- * Attempts to remove element without waiting.
274
- * Returns undefined if queue is empty.
275
- */
276
- tryTake(): T | undefined;
277
-
278
- /**
279
- * Returns next element without removing it.
280
- * Waits for an element if queue is empty.
281
- */
282
- peek(): Promise<T>;
283
-
284
- /**
285
- * Closes the queue, preventing further additions.
286
- * Allows existing elements to be consumed.
287
- */
288
- close(): void;
289
-
290
- /**
291
- * Returns 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
- * 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
- * Attempts to transfer element to waiting consumer.
314
- * Returns 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
- * Returns true if there are consumers waiting to receive elements.
323
- */
324
- readonly hasWaitingConsumer: boolean;
325
-
326
- /**
327
- * Returns 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
- * 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
- * Returns the delay (in ms) until next element becomes available.
349
- * Returns 0 if element is ready now.
350
- * Returns Infinity if queue is empty.
351
- */
352
- readonly nextDelay: number;
353
- }
@@ -1,158 +0,0 @@
1
- /**
2
- * Set interfaces that mirror Java's Set interface hierarchy.
3
- *
4
- * Sets are collections that contain no duplicate elements.
5
- * They provide 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
- * Returns true if this set contains the specified element.
17
- */
18
- contains(element: T): boolean;
19
-
20
- /**
21
- * Returns 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
- * 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
- * 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
- * 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
- * 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
- * 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
- * Returns the comparator used to order elements in this set.
80
- */
81
- readonly comparator: Compare<T>;
82
-
83
- /**
84
- * Returns the first (lowest) element in this set.
85
- *
86
- * @throws Error if set is empty
87
- */
88
- first(): T;
89
-
90
- /**
91
- * Returns the last (highest) element in this set.
92
- *
93
- * @throws Error if set is empty
94
- */
95
- last(): T;
96
-
97
- /**
98
- * Returns 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
- * Returns 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
- * Returns 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
- * Returns 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
- * Returns 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
- * Returns the greatest element strictly less than the given element, or undefined if none.
131
- */
132
- lower(element: T): T | undefined;
133
-
134
- /**
135
- * Returns 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 returns undefined if empty.
141
- */
142
- pollFirst(): T | undefined;
143
-
144
- /**
145
- * Retrieves and removes the last (highest) element, or returns undefined if empty.
146
- */
147
- pollLast(): T | undefined;
148
-
149
- /**
150
- * Returns a reverse order view of this set.
151
- */
152
- descendingSet(): NavigableSet<T>;
153
-
154
- /**
155
- * Returns a reverse order iterator over the elements in this set.
156
- */
157
- descendingIterator(): Iterator<T>;
158
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * The order of a list as data (Graph's split, wave 2, W1). 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";