@elaraai/east 0.0.1-beta.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.md +682 -0
- package/README.md +276 -0
- package/dist/src/analyze.d.ts +95 -0
- package/dist/src/analyze.d.ts.map +1 -0
- package/dist/src/analyze.js +1110 -0
- package/dist/src/analyze.js.map +1 -0
- package/dist/src/ast.d.ts +263 -0
- package/dist/src/ast.d.ts.map +1 -0
- package/dist/src/ast.js +151 -0
- package/dist/src/ast.js.map +1 -0
- package/dist/src/ast_to_ir.d.ts +24 -0
- package/dist/src/ast_to_ir.d.ts.map +1 -0
- package/dist/src/ast_to_ir.js +834 -0
- package/dist/src/ast_to_ir.js.map +1 -0
- package/dist/src/builtins.d.ts +18 -0
- package/dist/src/builtins.d.ts.map +1 -0
- package/dist/src/builtins.js +1105 -0
- package/dist/src/builtins.js.map +1 -0
- package/dist/src/comparison.d.ts +28 -0
- package/dist/src/comparison.d.ts.map +1 -0
- package/dist/src/comparison.js +1017 -0
- package/dist/src/comparison.js.map +1 -0
- package/dist/src/compile.d.ts +22 -0
- package/dist/src/compile.d.ts.map +1 -0
- package/dist/src/compile.js +3260 -0
- package/dist/src/compile.js.map +1 -0
- package/dist/src/containers/ref.d.ts +106 -0
- package/dist/src/containers/ref.d.ts.map +1 -0
- package/dist/src/containers/ref.js +100 -0
- package/dist/src/containers/ref.js.map +1 -0
- package/dist/src/containers/sortedmap.d.ts +165 -0
- package/dist/src/containers/sortedmap.d.ts.map +1 -0
- package/dist/src/containers/sortedmap.js +237 -0
- package/dist/src/containers/sortedmap.js.map +1 -0
- package/dist/src/containers/sortedset.d.ts +185 -0
- package/dist/src/containers/sortedset.d.ts.map +1 -0
- package/dist/src/containers/sortedset.js +312 -0
- package/dist/src/containers/sortedset.js.map +1 -0
- package/dist/src/containers/variant.d.ts +131 -0
- package/dist/src/containers/variant.d.ts.map +1 -0
- package/dist/src/containers/variant.js +68 -0
- package/dist/src/containers/variant.js.map +1 -0
- package/dist/src/datetime_format/parse.d.ts +50 -0
- package/dist/src/datetime_format/parse.d.ts.map +1 -0
- package/dist/src/datetime_format/parse.js +908 -0
- package/dist/src/datetime_format/parse.js.map +1 -0
- package/dist/src/datetime_format/print.d.ts +35 -0
- package/dist/src/datetime_format/print.d.ts.map +1 -0
- package/dist/src/datetime_format/print.js +157 -0
- package/dist/src/datetime_format/print.js.map +1 -0
- package/dist/src/datetime_format/tokenize.d.ts +76 -0
- package/dist/src/datetime_format/tokenize.d.ts.map +1 -0
- package/dist/src/datetime_format/tokenize.js +271 -0
- package/dist/src/datetime_format/tokenize.js.map +1 -0
- package/dist/src/datetime_format/types.d.ts +99 -0
- package/dist/src/datetime_format/types.d.ts.map +1 -0
- package/dist/src/datetime_format/types.js +103 -0
- package/dist/src/datetime_format/types.js.map +1 -0
- package/dist/src/datetime_format/validate.d.ts +51 -0
- package/dist/src/datetime_format/validate.d.ts.map +1 -0
- package/dist/src/datetime_format/validate.js +208 -0
- package/dist/src/datetime_format/validate.js.map +1 -0
- package/dist/src/default.d.ts +21 -0
- package/dist/src/default.d.ts.map +1 -0
- package/dist/src/default.js +82 -0
- package/dist/src/default.js.map +1 -0
- package/dist/src/eastir.d.ts +33 -0
- package/dist/src/eastir.d.ts.map +1 -0
- package/dist/src/eastir.js +92 -0
- package/dist/src/eastir.js.map +1 -0
- package/dist/src/error.d.ts +13 -0
- package/dist/src/error.d.ts.map +1 -0
- package/dist/src/error.js +8 -0
- package/dist/src/error.js.map +1 -0
- package/dist/src/expr/array.d.ts +1711 -0
- package/dist/src/expr/array.d.ts.map +1 -0
- package/dist/src/expr/array.js +1805 -0
- package/dist/src/expr/array.js.map +1 -0
- package/dist/src/expr/ast.d.ts +17 -0
- package/dist/src/expr/ast.d.ts.map +1 -0
- package/dist/src/expr/ast.js +302 -0
- package/dist/src/expr/ast.js.map +1 -0
- package/dist/src/expr/blob.d.ts +141 -0
- package/dist/src/expr/blob.d.ts.map +1 -0
- package/dist/src/expr/blob.js +198 -0
- package/dist/src/expr/blob.js.map +1 -0
- package/dist/src/expr/block.d.ts +201 -0
- package/dist/src/expr/block.d.ts.map +1 -0
- package/dist/src/expr/block.js +1505 -0
- package/dist/src/expr/block.js.map +1 -0
- package/dist/src/expr/boolean.d.ts +207 -0
- package/dist/src/expr/boolean.d.ts.map +1 -0
- package/dist/src/expr/boolean.js +261 -0
- package/dist/src/expr/boolean.js.map +1 -0
- package/dist/src/expr/datetime.d.ts +544 -0
- package/dist/src/expr/datetime.d.ts.map +1 -0
- package/dist/src/expr/datetime.js +980 -0
- package/dist/src/expr/datetime.js.map +1 -0
- package/dist/src/expr/dict.d.ts +1242 -0
- package/dist/src/expr/dict.d.ts.map +1 -0
- package/dist/src/expr/dict.js +1492 -0
- package/dist/src/expr/dict.js.map +1 -0
- package/dist/src/expr/expr.d.ts +95 -0
- package/dist/src/expr/expr.d.ts.map +1 -0
- package/dist/src/expr/expr.js +171 -0
- package/dist/src/expr/expr.js.map +1 -0
- package/dist/src/expr/float.d.ts +357 -0
- package/dist/src/expr/float.d.ts.map +1 -0
- package/dist/src/expr/float.js +637 -0
- package/dist/src/expr/float.js.map +1 -0
- package/dist/src/expr/function.d.ts +46 -0
- package/dist/src/expr/function.d.ts.map +1 -0
- package/dist/src/expr/function.js +58 -0
- package/dist/src/expr/function.js.map +1 -0
- package/dist/src/expr/index.d.ts +450 -0
- package/dist/src/expr/index.d.ts.map +1 -0
- package/dist/src/expr/index.js +423 -0
- package/dist/src/expr/index.js.map +1 -0
- package/dist/src/expr/integer.d.ts +256 -0
- package/dist/src/expr/integer.d.ts.map +1 -0
- package/dist/src/expr/integer.js +311 -0
- package/dist/src/expr/integer.js.map +1 -0
- package/dist/src/expr/libs/array.d.ts +106 -0
- package/dist/src/expr/libs/array.d.ts.map +1 -0
- package/dist/src/expr/libs/array.js +140 -0
- package/dist/src/expr/libs/array.js.map +1 -0
- package/dist/src/expr/libs/blob.d.ts +42 -0
- package/dist/src/expr/libs/blob.d.ts.map +1 -0
- package/dist/src/expr/libs/blob.js +70 -0
- package/dist/src/expr/libs/blob.js.map +1 -0
- package/dist/src/expr/libs/datetime.d.ts +479 -0
- package/dist/src/expr/libs/datetime.d.ts.map +1 -0
- package/dist/src/expr/libs/datetime.js +624 -0
- package/dist/src/expr/libs/datetime.js.map +1 -0
- package/dist/src/expr/libs/dict.d.ts +66 -0
- package/dist/src/expr/libs/dict.d.ts.map +1 -0
- package/dist/src/expr/libs/dict.js +77 -0
- package/dist/src/expr/libs/dict.js.map +1 -0
- package/dist/src/expr/libs/float.d.ts +299 -0
- package/dist/src/expr/libs/float.d.ts.map +1 -0
- package/dist/src/expr/libs/float.js +564 -0
- package/dist/src/expr/libs/float.js.map +1 -0
- package/dist/src/expr/libs/integer.d.ts +228 -0
- package/dist/src/expr/libs/integer.d.ts.map +1 -0
- package/dist/src/expr/libs/integer.js +398 -0
- package/dist/src/expr/libs/integer.js.map +1 -0
- package/dist/src/expr/libs/set.d.ts +59 -0
- package/dist/src/expr/libs/set.d.ts.map +1 -0
- package/dist/src/expr/libs/set.js +69 -0
- package/dist/src/expr/libs/set.js.map +1 -0
- package/dist/src/expr/libs/string.d.ts +71 -0
- package/dist/src/expr/libs/string.d.ts.map +1 -0
- package/dist/src/expr/libs/string.js +75 -0
- package/dist/src/expr/libs/string.js.map +1 -0
- package/dist/src/expr/never.d.ts +15 -0
- package/dist/src/expr/never.d.ts.map +1 -0
- package/dist/src/expr/never.js +12 -0
- package/dist/src/expr/never.js.map +1 -0
- package/dist/src/expr/null.d.ts +15 -0
- package/dist/src/expr/null.d.ts.map +1 -0
- package/dist/src/expr/null.js +12 -0
- package/dist/src/expr/null.js.map +1 -0
- package/dist/src/expr/ref.d.ts +103 -0
- package/dist/src/expr/ref.d.ts.map +1 -0
- package/dist/src/expr/ref.js +131 -0
- package/dist/src/expr/ref.js.map +1 -0
- package/dist/src/expr/regex_validation.d.ts +25 -0
- package/dist/src/expr/regex_validation.d.ts.map +1 -0
- package/dist/src/expr/regex_validation.js +130 -0
- package/dist/src/expr/regex_validation.js.map +1 -0
- package/dist/src/expr/set.d.ts +1071 -0
- package/dist/src/expr/set.d.ts.map +1 -0
- package/dist/src/expr/set.js +1137 -0
- package/dist/src/expr/set.js.map +1 -0
- package/dist/src/expr/string.d.ts +414 -0
- package/dist/src/expr/string.d.ts.map +1 -0
- package/dist/src/expr/string.js +683 -0
- package/dist/src/expr/string.js.map +1 -0
- package/dist/src/expr/struct.d.ts +48 -0
- package/dist/src/expr/struct.d.ts.map +1 -0
- package/dist/src/expr/struct.js +65 -0
- package/dist/src/expr/struct.js.map +1 -0
- package/dist/src/expr/types.d.ts +68 -0
- package/dist/src/expr/types.d.ts.map +1 -0
- package/dist/src/expr/types.js +6 -0
- package/dist/src/expr/types.js.map +1 -0
- package/dist/src/expr/variant.d.ts +137 -0
- package/dist/src/expr/variant.d.ts.map +1 -0
- package/dist/src/expr/variant.js +105 -0
- package/dist/src/expr/variant.js.map +1 -0
- package/dist/src/fuzz.d.ts +80 -0
- package/dist/src/fuzz.d.ts.map +1 -0
- package/dist/src/fuzz.js +300 -0
- package/dist/src/fuzz.js.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal.d.ts +36 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +11 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/ir.d.ts +1571 -0
- package/dist/src/ir.d.ts.map +1 -0
- package/dist/src/ir.js +56 -0
- package/dist/src/ir.js.map +1 -0
- package/dist/src/location.d.ts +48 -0
- package/dist/src/location.d.ts.map +1 -0
- package/dist/src/location.js +62 -0
- package/dist/src/location.js.map +1 -0
- package/dist/src/platform.d.ts +21 -0
- package/dist/src/platform.d.ts.map +1 -0
- package/dist/src/platform.js +8 -0
- package/dist/src/platform.js.map +1 -0
- package/dist/src/serialization/beast.d.ts +39 -0
- package/dist/src/serialization/beast.d.ts.map +1 -0
- package/dist/src/serialization/beast.js +555 -0
- package/dist/src/serialization/beast.js.map +1 -0
- package/dist/src/serialization/beast2-stream.d.ts +38 -0
- package/dist/src/serialization/beast2-stream.d.ts.map +1 -0
- package/dist/src/serialization/beast2-stream.js +665 -0
- package/dist/src/serialization/beast2-stream.js.map +1 -0
- package/dist/src/serialization/beast2.d.ts +41 -0
- package/dist/src/serialization/beast2.d.ts.map +1 -0
- package/dist/src/serialization/beast2.js +489 -0
- package/dist/src/serialization/beast2.js.map +1 -0
- package/dist/src/serialization/binary-utils.d.ts +151 -0
- package/dist/src/serialization/binary-utils.d.ts.map +1 -0
- package/dist/src/serialization/binary-utils.js +929 -0
- package/dist/src/serialization/binary-utils.js.map +1 -0
- package/dist/src/serialization/east.d.ts +84 -0
- package/dist/src/serialization/east.d.ts.map +1 -0
- package/dist/src/serialization/east.js +1802 -0
- package/dist/src/serialization/east.js.map +1 -0
- package/dist/src/serialization/index.d.ts +11 -0
- package/dist/src/serialization/index.d.ts.map +1 -0
- package/dist/src/serialization/index.js +12 -0
- package/dist/src/serialization/index.js.map +1 -0
- package/dist/src/serialization/json.d.ts +36 -0
- package/dist/src/serialization/json.d.ts.map +1 -0
- package/dist/src/serialization/json.js +849 -0
- package/dist/src/serialization/json.js.map +1 -0
- package/dist/src/type_of_type.d.ts +115 -0
- package/dist/src/type_of_type.d.ts.map +1 -0
- package/dist/src/type_of_type.js +362 -0
- package/dist/src/type_of_type.js.map +1 -0
- package/dist/src/types.d.ts +648 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +1631 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sorted map implementation using a B-tree data structure.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam K - The type of keys in the map
|
|
5
|
+
* @typeParam T - The type of values in the map
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Implements the ES6 `Map` interface with additional capabilities:
|
|
9
|
+
* - Maintains entries in sorted order by key based on a comparison function
|
|
10
|
+
* - Supports {@link minKey} and {@link maxKey} for accessing key extrema
|
|
11
|
+
* - Provides range-based iteration starting from any key
|
|
12
|
+
* - Respects frozen state and throws errors on modification attempts
|
|
13
|
+
* - Includes static {@link groupBy} method for aggregation operations
|
|
14
|
+
*
|
|
15
|
+
* Used to implement East's {@link DictType} with total ordering semantics.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SortedMap<K, T> implements Map<K, T> {
|
|
18
|
+
private btree;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new SortedMap.
|
|
21
|
+
*
|
|
22
|
+
* @param values - Optional initial entries as `[key, value]` pairs
|
|
23
|
+
* @param compare - Optional comparison function for ordering keys
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* If no comparison function is provided, keys are compared using default ordering.
|
|
27
|
+
*/
|
|
28
|
+
constructor(values?: Iterable<[K, T]>, compare?: (a: K, b: K) => number);
|
|
29
|
+
/** The number of key-value pairs in the map. */
|
|
30
|
+
get size(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves the value associated with a key.
|
|
33
|
+
*
|
|
34
|
+
* @param key - The key to look up
|
|
35
|
+
* @returns The associated value, or `undefined` if the key is not present
|
|
36
|
+
*/
|
|
37
|
+
get(key: K): T | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Associates a value with a key in the map.
|
|
40
|
+
*
|
|
41
|
+
* @param key - The key to set
|
|
42
|
+
* @param value - The value to associate with the key
|
|
43
|
+
* @returns This map for chaining
|
|
44
|
+
* @throws {TypeError} When the map is frozen
|
|
45
|
+
*/
|
|
46
|
+
set(key: K, value: T): this;
|
|
47
|
+
/**
|
|
48
|
+
* Removes all entries from the map.
|
|
49
|
+
*
|
|
50
|
+
* @throws {TypeError} When the map is frozen
|
|
51
|
+
*/
|
|
52
|
+
clear(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Removes a key-value pair from the map.
|
|
55
|
+
*
|
|
56
|
+
* @param value - The key to remove
|
|
57
|
+
* @returns `true` if the key was present and removed, `false` otherwise
|
|
58
|
+
* @throws {TypeError} When the map is frozen
|
|
59
|
+
*/
|
|
60
|
+
delete(value: K): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if a key exists in the map.
|
|
63
|
+
*
|
|
64
|
+
* @param value - The key to check
|
|
65
|
+
* @returns `true` if the key is present, `false` otherwise
|
|
66
|
+
*/
|
|
67
|
+
has(value: K): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Executes a callback for each entry in the map, in sorted order by key.
|
|
70
|
+
*
|
|
71
|
+
* @param callbackfn - Function to execute for each entry
|
|
72
|
+
* @param thisArg - Value to use as `this` when executing the callback
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* The callback receives the value, key, and map (in that order for ES6 Map compatibility).
|
|
76
|
+
*/
|
|
77
|
+
forEach(callbackfn: (value: T, key: K, set: Map<K, T>) => void, thisArg?: any): void;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the smallest key in the map.
|
|
80
|
+
*
|
|
81
|
+
* @returns The minimum key, or `undefined` if the map is empty
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
85
|
+
*/
|
|
86
|
+
minKey(): K | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the largest key in the map.
|
|
89
|
+
*
|
|
90
|
+
* @returns The maximum key, or `undefined` if the map is empty
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
94
|
+
*/
|
|
95
|
+
maxKey(): K | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Returns an iterator over the map's keys in sorted order.
|
|
98
|
+
*
|
|
99
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
100
|
+
* @returns An iterator yielding keys in sorted order
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* If `firstKey` is provided, iteration starts from that key (or the next key if not present).
|
|
104
|
+
* This enables efficient range queries over sorted data.
|
|
105
|
+
*/
|
|
106
|
+
keys(firstKey?: K | undefined): MapIterator<K>;
|
|
107
|
+
/**
|
|
108
|
+
* Returns an iterator over the map's values in key-sorted order.
|
|
109
|
+
*
|
|
110
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
111
|
+
* @returns An iterator yielding values in key-sorted order
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Values are returned in the order of their sorted keys, not sorted by value.
|
|
115
|
+
*/
|
|
116
|
+
values(firstKey?: K | undefined): MapIterator<T>;
|
|
117
|
+
/**
|
|
118
|
+
* Returns an iterator over the map's entries in sorted order by key.
|
|
119
|
+
*
|
|
120
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
121
|
+
* @returns An iterator yielding `[key, value]` tuples in key-sorted order
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* If `firstKey` is provided, iteration starts from that key.
|
|
125
|
+
*/
|
|
126
|
+
entries(firstKey?: K | undefined): MapIterator<[K, T]>;
|
|
127
|
+
/**
|
|
128
|
+
* Returns an iterator over the map's entries in sorted order by key.
|
|
129
|
+
*
|
|
130
|
+
* @returns An iterator yielding `[key, value]` tuples in key-sorted order
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* Makes {@link SortedMap} iterable with `for...of` loops.
|
|
134
|
+
*/
|
|
135
|
+
[Symbol.iterator](): MapIterator<[K, T]>;
|
|
136
|
+
/** Returns the string tag for this object type. */
|
|
137
|
+
get [Symbol.toStringTag](): string;
|
|
138
|
+
/**
|
|
139
|
+
* Groups items into a sorted map based on a key selector function.
|
|
140
|
+
*
|
|
141
|
+
* @typeParam K - The type of keys to group by
|
|
142
|
+
* @typeParam T - The type of items to group
|
|
143
|
+
* @param items - The items to group
|
|
144
|
+
* @param keySelector - Function that extracts the grouping key from each item
|
|
145
|
+
* @param compare - Optional comparison function for ordering keys
|
|
146
|
+
* @returns A {@link SortedMap} where each key maps to an array of items with that key
|
|
147
|
+
*
|
|
148
|
+
* @remarks
|
|
149
|
+
* This is a convenient aggregation function similar to SQL's `GROUP BY`.
|
|
150
|
+
* Items with the same key are collected into arrays in the order they appear.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* const people = [
|
|
155
|
+
* { name: "Alice", age: 30 },
|
|
156
|
+
* { name: "Bob", age: 25 },
|
|
157
|
+
* { name: "Charlie", age: 30 }
|
|
158
|
+
* ];
|
|
159
|
+
* const byAge = SortedMap.groupBy(people, p => p.age);
|
|
160
|
+
* // Result: Map { 25 => [{name:"Bob",age:25}], 30 => [{name:"Alice",age:30}, {name:"Charlie",age:30}] }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
static groupBy<K, T>(items: Iterable<T>, keySelector: (item: T) => K, compare?: (a: K, b: K) => number): SortedMap<K, T[]>;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=sortedmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortedmap.d.ts","sourceRoot":"","sources":["../../../src/containers/sortedmap.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAc;IAE3B;;;;;;;;OAQG;gBACS,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IAStE,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAA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EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;CAa7H"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import sorted_btree from "sorted-btree";
|
|
6
|
+
// Deal with CJS default import
|
|
7
|
+
const BTree = sorted_btree.default;
|
|
8
|
+
/**
|
|
9
|
+
* A sorted map implementation using a B-tree data structure.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam K - The type of keys in the map
|
|
12
|
+
* @typeParam T - The type of values in the map
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Implements the ES6 `Map` interface with additional capabilities:
|
|
16
|
+
* - Maintains entries in sorted order by key based on a comparison function
|
|
17
|
+
* - Supports {@link minKey} and {@link maxKey} for accessing key extrema
|
|
18
|
+
* - Provides range-based iteration starting from any key
|
|
19
|
+
* - Respects frozen state and throws errors on modification attempts
|
|
20
|
+
* - Includes static {@link groupBy} method for aggregation operations
|
|
21
|
+
*
|
|
22
|
+
* Used to implement East's {@link DictType} with total ordering semantics.
|
|
23
|
+
*/
|
|
24
|
+
export class SortedMap {
|
|
25
|
+
btree;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new SortedMap.
|
|
28
|
+
*
|
|
29
|
+
* @param values - Optional initial entries as `[key, value]` pairs
|
|
30
|
+
* @param compare - Optional comparison function for ordering keys
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* If no comparison function is provided, keys are compared using default ordering.
|
|
34
|
+
*/
|
|
35
|
+
constructor(values, compare) {
|
|
36
|
+
this.btree = new BTree(undefined, compare);
|
|
37
|
+
if (values !== undefined) {
|
|
38
|
+
for (const [key, value] of values) {
|
|
39
|
+
this.btree.set(key, value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The number of key-value pairs in the map. */
|
|
44
|
+
get size() {
|
|
45
|
+
return this.btree.size;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the value associated with a key.
|
|
49
|
+
*
|
|
50
|
+
* @param key - The key to look up
|
|
51
|
+
* @returns The associated value, or `undefined` if the key is not present
|
|
52
|
+
*/
|
|
53
|
+
get(key) {
|
|
54
|
+
return this.btree.get(key);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Associates a value with a key in the map.
|
|
58
|
+
*
|
|
59
|
+
* @param key - The key to set
|
|
60
|
+
* @param value - The value to associate with the key
|
|
61
|
+
* @returns This map for chaining
|
|
62
|
+
* @throws {TypeError} When the map is frozen
|
|
63
|
+
*/
|
|
64
|
+
set(key, value) {
|
|
65
|
+
if (Object.isFrozen(this)) {
|
|
66
|
+
throw new TypeError("Cannot modify frozen SortedMap");
|
|
67
|
+
}
|
|
68
|
+
this.btree.set(key, value);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Removes all entries from the map.
|
|
73
|
+
*
|
|
74
|
+
* @throws {TypeError} When the map is frozen
|
|
75
|
+
*/
|
|
76
|
+
clear() {
|
|
77
|
+
if (Object.isFrozen(this)) {
|
|
78
|
+
throw new TypeError("Cannot modify frozen SortedMap");
|
|
79
|
+
}
|
|
80
|
+
this.btree.clear();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Removes a key-value pair from the map.
|
|
84
|
+
*
|
|
85
|
+
* @param value - The key to remove
|
|
86
|
+
* @returns `true` if the key was present and removed, `false` otherwise
|
|
87
|
+
* @throws {TypeError} When the map is frozen
|
|
88
|
+
*/
|
|
89
|
+
delete(value) {
|
|
90
|
+
if (Object.isFrozen(this)) {
|
|
91
|
+
throw new TypeError("Cannot modify frozen SortedMap");
|
|
92
|
+
}
|
|
93
|
+
return this.btree.delete(value);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Checks if a key exists in the map.
|
|
97
|
+
*
|
|
98
|
+
* @param value - The key to check
|
|
99
|
+
* @returns `true` if the key is present, `false` otherwise
|
|
100
|
+
*/
|
|
101
|
+
has(value) {
|
|
102
|
+
return this.btree.has(value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Executes a callback for each entry in the map, in sorted order by key.
|
|
106
|
+
*
|
|
107
|
+
* @param callbackfn - Function to execute for each entry
|
|
108
|
+
* @param thisArg - Value to use as `this` when executing the callback
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* The callback receives the value, key, and map (in that order for ES6 Map compatibility).
|
|
112
|
+
*/
|
|
113
|
+
forEach(callbackfn, thisArg) {
|
|
114
|
+
for (const [key, value] of this.btree.entries()) {
|
|
115
|
+
callbackfn.call(thisArg, value, key, this);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the smallest key in the map.
|
|
120
|
+
*
|
|
121
|
+
* @returns The minimum key, or `undefined` if the map is empty
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
125
|
+
*/
|
|
126
|
+
minKey() {
|
|
127
|
+
return this.btree.minKey();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the largest key in the map.
|
|
131
|
+
*
|
|
132
|
+
* @returns The maximum key, or `undefined` if the map is empty
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
136
|
+
*/
|
|
137
|
+
maxKey() {
|
|
138
|
+
return this.btree.maxKey();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns an iterator over the map's keys in sorted order.
|
|
142
|
+
*
|
|
143
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
144
|
+
* @returns An iterator yielding keys in sorted order
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* If `firstKey` is provided, iteration starts from that key (or the next key if not present).
|
|
148
|
+
* This enables efficient range queries over sorted data.
|
|
149
|
+
*/
|
|
150
|
+
keys(firstKey) {
|
|
151
|
+
return Iterator.from(this.btree.keys(firstKey));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns an iterator over the map's values in key-sorted order.
|
|
155
|
+
*
|
|
156
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
157
|
+
* @returns An iterator yielding values in key-sorted order
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Values are returned in the order of their sorted keys, not sorted by value.
|
|
161
|
+
*/
|
|
162
|
+
values(firstKey) {
|
|
163
|
+
return Iterator.from(this.btree.values(firstKey));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns an iterator over the map's entries in sorted order by key.
|
|
167
|
+
*
|
|
168
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
169
|
+
* @returns An iterator yielding `[key, value]` tuples in key-sorted order
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* If `firstKey` is provided, iteration starts from that key.
|
|
173
|
+
*/
|
|
174
|
+
entries(firstKey) {
|
|
175
|
+
const gen = (function* (btree) {
|
|
176
|
+
for (const [key, value] of btree.entries(firstKey)) {
|
|
177
|
+
yield [key, value];
|
|
178
|
+
}
|
|
179
|
+
})(this.btree);
|
|
180
|
+
return Iterator.from(gen);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns an iterator over the map's entries in sorted order by key.
|
|
184
|
+
*
|
|
185
|
+
* @returns An iterator yielding `[key, value]` tuples in key-sorted order
|
|
186
|
+
*
|
|
187
|
+
* @remarks
|
|
188
|
+
* Makes {@link SortedMap} iterable with `for...of` loops.
|
|
189
|
+
*/
|
|
190
|
+
[Symbol.iterator]() {
|
|
191
|
+
return Iterator.from(this.btree.entries());
|
|
192
|
+
}
|
|
193
|
+
/** Returns the string tag for this object type. */
|
|
194
|
+
get [Symbol.toStringTag]() {
|
|
195
|
+
return "SortedMap";
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Groups items into a sorted map based on a key selector function.
|
|
199
|
+
*
|
|
200
|
+
* @typeParam K - The type of keys to group by
|
|
201
|
+
* @typeParam T - The type of items to group
|
|
202
|
+
* @param items - The items to group
|
|
203
|
+
* @param keySelector - Function that extracts the grouping key from each item
|
|
204
|
+
* @param compare - Optional comparison function for ordering keys
|
|
205
|
+
* @returns A {@link SortedMap} where each key maps to an array of items with that key
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* This is a convenient aggregation function similar to SQL's `GROUP BY`.
|
|
209
|
+
* Items with the same key are collected into arrays in the order they appear.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const people = [
|
|
214
|
+
* { name: "Alice", age: 30 },
|
|
215
|
+
* { name: "Bob", age: 25 },
|
|
216
|
+
* { name: "Charlie", age: 30 }
|
|
217
|
+
* ];
|
|
218
|
+
* const byAge = SortedMap.groupBy(people, p => p.age);
|
|
219
|
+
* // Result: Map { 25 => [{name:"Bob",age:25}], 30 => [{name:"Alice",age:30}, {name:"Charlie",age:30}] }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
static groupBy(items, keySelector, compare) {
|
|
223
|
+
const map = new SortedMap(undefined, compare);
|
|
224
|
+
for (const item of items) {
|
|
225
|
+
const key = keySelector(item);
|
|
226
|
+
const group = map.get(key);
|
|
227
|
+
if (group === undefined) {
|
|
228
|
+
map.set(key, [item]);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
group.push(item);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return map;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=sortedmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortedmap.js","sourceRoot":"","sources":["../../../src/containers/sortedmap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,+BAA+B;AAC/B,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC;AAGnC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,SAAS;IACV,KAAK,CAAc;IAE3B;;;;;;;;OAQG;IACH,YAAY,MAAwB,EAAE,OAAgC;QAClE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;gBAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;IAED,gDAAgD;IAChD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,GAAM,EAAE,KAAQ;QAChB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,KAAK;QAC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C,CAAC;YACrB,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sorted set implementation using a B-tree data structure.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam K - The type of keys stored in the set
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Implements the ES6 `Set` interface with additional capabilities:
|
|
8
|
+
* - Maintains keys in sorted order based on a comparison function
|
|
9
|
+
* - Supports {@link minKey} and {@link maxKey} for accessing extrema
|
|
10
|
+
* - Provides range-based iteration starting from any key
|
|
11
|
+
* - Implements ES2024 set operations (union, intersection, difference, etc.)
|
|
12
|
+
* - Respects frozen state and throws errors on modification attempts
|
|
13
|
+
*
|
|
14
|
+
* Used to implement East's {@link SetType} with total ordering semantics.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SortedSet<K> implements Set<K> {
|
|
17
|
+
private compare?;
|
|
18
|
+
private btree;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new SortedSet.
|
|
21
|
+
*
|
|
22
|
+
* @param values - Optional initial values to add to the set
|
|
23
|
+
* @param compare - Optional comparison function for ordering keys
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* If no comparison function is provided, keys are compared using default ordering.
|
|
27
|
+
*/
|
|
28
|
+
constructor(values?: Iterable<K>, compare?: ((a: K, b: K) => number) | undefined);
|
|
29
|
+
/** The number of elements in the set. */
|
|
30
|
+
get size(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Adds a value to the set.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The value to add
|
|
35
|
+
* @returns This set for chaining
|
|
36
|
+
* @throws {TypeError} When the set is frozen
|
|
37
|
+
*/
|
|
38
|
+
add(value: K): this;
|
|
39
|
+
/**
|
|
40
|
+
* Removes all elements from the set.
|
|
41
|
+
*
|
|
42
|
+
* @throws {TypeError} When the set is frozen
|
|
43
|
+
*/
|
|
44
|
+
clear(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes a value from the set.
|
|
47
|
+
*
|
|
48
|
+
* @param value - The value to remove
|
|
49
|
+
* @returns `true` if the value was present and removed, `false` otherwise
|
|
50
|
+
* @throws {TypeError} When the set is frozen
|
|
51
|
+
*/
|
|
52
|
+
delete(value: K): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Checks if a value exists in the set.
|
|
55
|
+
*
|
|
56
|
+
* @param value - The value to check
|
|
57
|
+
* @returns `true` if the value is present, `false` otherwise
|
|
58
|
+
*/
|
|
59
|
+
has(value: K): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Executes a callback for each value in the set, in sorted order.
|
|
62
|
+
*
|
|
63
|
+
* @param callbackfn - Function to execute for each element
|
|
64
|
+
* @param thisArg - Value to use as `this` when executing the callback
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* The callback receives the value twice (for ES6 Set compatibility) and the set itself.
|
|
68
|
+
*/
|
|
69
|
+
forEach(callbackfn: (value: K, value2: K, set: Set<K>) => void, thisArg?: any): void;
|
|
70
|
+
/**
|
|
71
|
+
* Returns a new set containing all elements from this set and another.
|
|
72
|
+
*
|
|
73
|
+
* @typeParam U - The type of elements in the other set
|
|
74
|
+
* @param other - The set to union with
|
|
75
|
+
* @returns A new {@link SortedSet} containing all elements from both sets
|
|
76
|
+
*/
|
|
77
|
+
union<U>(other: ReadonlySetLike<U>): SortedSet<K | U>;
|
|
78
|
+
/**
|
|
79
|
+
* Returns a new set containing only elements present in both sets.
|
|
80
|
+
*
|
|
81
|
+
* @typeParam U - The type of elements in the other set
|
|
82
|
+
* @param other - The set to intersect with
|
|
83
|
+
* @returns A new {@link SortedSet} containing common elements
|
|
84
|
+
*/
|
|
85
|
+
intersection<U>(other: ReadonlySetLike<U>): SortedSet<K & U>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns a new set containing elements in this set but not in another.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam U - The type of elements in the other set
|
|
90
|
+
* @param other - The set to subtract
|
|
91
|
+
* @returns A new {@link SortedSet} with elements only in this set
|
|
92
|
+
*/
|
|
93
|
+
difference<U>(other: ReadonlySetLike<U>): SortedSet<K>;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a new set containing elements in either set but not both.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam U - The type of elements in the other set
|
|
98
|
+
* @param other - The set to compare with
|
|
99
|
+
* @returns A new {@link SortedSet} with elements exclusive to each set
|
|
100
|
+
*/
|
|
101
|
+
symmetricDifference<U>(other: ReadonlySetLike<U>): SortedSet<K | U>;
|
|
102
|
+
/**
|
|
103
|
+
* Checks if this set is a subset of another set.
|
|
104
|
+
*
|
|
105
|
+
* @param other - The potential superset
|
|
106
|
+
* @returns `true` if all elements of this set are in the other set
|
|
107
|
+
*/
|
|
108
|
+
isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Checks if this set is a superset of another set.
|
|
111
|
+
*
|
|
112
|
+
* @param other - The potential subset
|
|
113
|
+
* @returns `true` if all elements of the other set are in this set
|
|
114
|
+
*/
|
|
115
|
+
isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if this set has no elements in common with another set.
|
|
118
|
+
*
|
|
119
|
+
* @param other - The set to compare with
|
|
120
|
+
* @returns `true` if the sets share no elements, `false` otherwise
|
|
121
|
+
*/
|
|
122
|
+
isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the smallest value in the set.
|
|
125
|
+
*
|
|
126
|
+
* @returns The minimum value, or `undefined` if the set is empty
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
130
|
+
*/
|
|
131
|
+
minKey(): K | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the largest value in the set.
|
|
134
|
+
*
|
|
135
|
+
* @returns The maximum value, or `undefined` if the set is empty
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* This is an O(log n) operation due to the B-tree structure.
|
|
139
|
+
*/
|
|
140
|
+
maxKey(): K | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Returns an iterator over the set's keys in sorted order.
|
|
143
|
+
*
|
|
144
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
145
|
+
* @returns An iterator yielding keys in sorted order
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* If `firstKey` is provided, iteration starts from that key (or the next key if not present).
|
|
149
|
+
* This enables efficient range queries over sorted data.
|
|
150
|
+
*/
|
|
151
|
+
keys(firstKey?: K | undefined): SetIterator<K>;
|
|
152
|
+
/**
|
|
153
|
+
* Returns an iterator over the set's values in sorted order.
|
|
154
|
+
*
|
|
155
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
156
|
+
* @returns An iterator yielding values in sorted order
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Identical to {@link keys} for sets (values and keys are the same).
|
|
160
|
+
*/
|
|
161
|
+
values(firstKey?: K | undefined): SetIterator<K>;
|
|
162
|
+
/**
|
|
163
|
+
* Returns an iterator over the set's entries in sorted order.
|
|
164
|
+
*
|
|
165
|
+
* @param firstKey - Optional starting key for range-based iteration
|
|
166
|
+
* @returns An iterator yielding `[key, key]` tuples in sorted order
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* For ES6 Set compatibility, entries are `[key, key]` tuples.
|
|
170
|
+
* If `firstKey` is provided, iteration starts from that key.
|
|
171
|
+
*/
|
|
172
|
+
entries(firstKey?: K | undefined): SetIterator<[K, K]>;
|
|
173
|
+
/**
|
|
174
|
+
* Returns an iterator over the set's values in sorted order.
|
|
175
|
+
*
|
|
176
|
+
* @returns An iterator yielding values in sorted order
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* Makes {@link SortedSet} iterable with `for...of` loops.
|
|
180
|
+
*/
|
|
181
|
+
[Symbol.iterator](): SetIterator<K>;
|
|
182
|
+
/** Returns the string tag for this object type. */
|
|
183
|
+
get [Symbol.toStringTag](): string;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=sortedset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortedset.d.ts","sourceRoot":"","sources":["../../../src/containers/sortedset.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,GAAG,CAAC,CAAC,CAAC;IAYL,OAAO,CAAC,OAAO,CAAC;IAXlD,OAAO,CAAC,KAAK,CAAsB;IAEnC;;;;;;;;OAQG;gBACS,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAU,OAAO,CAAC,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,aAAA;IAS1E,yCAAyC;IACzC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;OAMG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAQnB;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAOb;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAOzB;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAItB;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IAMpF;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;IAcrD;;;;;;OAMG;IACH,YAA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