atomic-fns 1.1.7 → 2.0.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.
Files changed (216) hide show
  1. package/README.md +405 -60
  2. package/dist/array/index.d.ts +9 -0
  3. package/dist/array/index.js +9 -0
  4. package/dist/array/list.d.ts +99 -0
  5. package/dist/array/list.js +133 -0
  6. package/dist/array/sets.d.ts +130 -0
  7. package/dist/array/sets.js +213 -0
  8. package/dist/async/index.d.ts +6 -0
  9. package/dist/async/index.js +6 -0
  10. package/dist/async/retry.d.ts +38 -0
  11. package/dist/async/retry.js +56 -0
  12. package/dist/async/sleep.d.ts +42 -0
  13. package/dist/async/sleep.js +76 -0
  14. package/dist/collections/bisect.d.ts +103 -0
  15. package/dist/collections/bisect.js +157 -0
  16. package/dist/collections/deque.d.ts +67 -97
  17. package/dist/collections/deque.js +197 -249
  18. package/dist/collections/entries.d.ts +89 -0
  19. package/dist/collections/entries.js +131 -0
  20. package/dist/collections/frozen-set.d.ts +42 -0
  21. package/dist/collections/frozen-set.js +64 -0
  22. package/dist/collections/group.d.ts +141 -0
  23. package/dist/collections/group.js +241 -0
  24. package/dist/collections/heap.d.ts +64 -0
  25. package/dist/collections/heap.js +205 -0
  26. package/dist/collections/index.d.ts +15 -642
  27. package/dist/collections/index.js +14 -716
  28. package/dist/collections/internal/arrayKeys.d.ts +19 -0
  29. package/dist/collections/internal/arrayKeys.js +83 -0
  30. package/dist/collections/internal/invariants.d.ts +4 -0
  31. package/dist/collections/internal/invariants.js +12 -0
  32. package/dist/collections/internal/iterable.d.ts +25 -0
  33. package/dist/collections/internal/iterable.js +62 -0
  34. package/dist/collections/iterate.d.ts +162 -0
  35. package/dist/collections/iterate.js +188 -0
  36. package/dist/collections/lru-cache.d.ts +58 -0
  37. package/dist/collections/lru-cache.js +164 -0
  38. package/dist/collections/order.d.ts +19 -0
  39. package/dist/collections/order.js +38 -0
  40. package/dist/collections/shape.d.ts +32 -0
  41. package/dist/collections/shape.js +86 -0
  42. package/dist/collections/sorted-map.d.ts +171 -0
  43. package/dist/collections/sorted-map.js +845 -0
  44. package/dist/collections/sorted-set.d.ts +103 -0
  45. package/dist/collections/sorted-set.js +147 -0
  46. package/dist/collections/splay-tree.d.ts +82 -0
  47. package/dist/collections/splay-tree.js +354 -0
  48. package/dist/collections/trie.d.ts +58 -0
  49. package/dist/collections/trie.js +196 -0
  50. package/dist/decimal/currency.d.ts +211 -0
  51. package/dist/decimal/currency.js +321 -0
  52. package/dist/decimal/decimal.d.ts +299 -0
  53. package/dist/decimal/decimal.js +660 -0
  54. package/dist/decimal/index.d.ts +11 -145
  55. package/dist/decimal/index.js +10 -374
  56. package/dist/decimal/internal/bits.d.ts +2 -0
  57. package/dist/decimal/internal/bits.js +7 -0
  58. package/dist/decimal/internal/echo.d.ts +4 -0
  59. package/dist/decimal/internal/echo.js +6 -0
  60. package/dist/decimal/internal/isqrt.d.ts +9 -0
  61. package/dist/decimal/internal/isqrt.js +34 -0
  62. package/dist/decimal/internal/locale.d.ts +7 -0
  63. package/dist/decimal/internal/locale.js +24 -0
  64. package/dist/decimal/internal/minor-units.d.ts +2 -0
  65. package/dist/decimal/internal/minor-units.js +33 -0
  66. package/dist/decimal/internal/pow10.d.ts +24 -0
  67. package/dist/decimal/internal/pow10.js +96 -0
  68. package/dist/encoding/base64.d.ts +39 -0
  69. package/dist/encoding/base64.js +53 -0
  70. package/dist/encoding/hex.d.ts +23 -0
  71. package/dist/encoding/hex.js +34 -0
  72. package/dist/encoding/index.d.ts +6 -0
  73. package/dist/encoding/index.js +6 -0
  74. package/dist/function/debounce.d.ts +68 -0
  75. package/dist/function/debounce.js +203 -0
  76. package/dist/function/index.d.ts +6 -0
  77. package/dist/function/index.js +6 -0
  78. package/dist/function/shared.d.ts +2 -0
  79. package/dist/function/shared.js +5 -0
  80. package/dist/function/wrap.d.ts +130 -0
  81. package/dist/function/wrap.js +113 -0
  82. package/dist/hash/digest.d.ts +18 -0
  83. package/dist/hash/digest.js +26 -0
  84. package/dist/hash/hash.d.ts +22 -0
  85. package/dist/hash/hash.js +252 -0
  86. package/dist/hash/hashString.d.ts +13 -0
  87. package/dist/hash/hashString.js +53 -0
  88. package/dist/hash/index.d.ts +8 -0
  89. package/dist/hash/index.js +8 -0
  90. package/dist/hash/stableStringify.d.ts +19 -0
  91. package/dist/hash/stableStringify.js +102 -0
  92. package/dist/id/index.d.ts +7 -0
  93. package/dist/id/index.js +7 -0
  94. package/dist/id/nanoid.d.ts +16 -0
  95. package/dist/id/nanoid.js +65 -0
  96. package/dist/id/uniqueId.d.ts +14 -0
  97. package/dist/id/uniqueId.js +20 -0
  98. package/dist/id/uuid.d.ts +25 -0
  99. package/dist/id/uuid.js +64 -0
  100. package/dist/index.d.ts +15 -8
  101. package/dist/index.js +15 -8
  102. package/dist/internal/bytes.d.ts +11 -0
  103. package/dist/internal/bytes.js +33 -0
  104. package/dist/internal/codec.d.ts +11 -0
  105. package/dist/internal/codec.js +84 -0
  106. package/dist/internal/compare.d.ts +10 -0
  107. package/dist/internal/compare.js +26 -0
  108. package/dist/internal/crypto.d.ts +5 -0
  109. package/dist/internal/crypto.js +11 -0
  110. package/dist/internal/keys.d.ts +12 -0
  111. package/dist/internal/keys.js +23 -0
  112. package/dist/internal/kind.d.ts +44 -0
  113. package/dist/internal/kind.js +139 -0
  114. package/dist/internal/sparse.d.ts +51 -0
  115. package/dist/internal/sparse.js +104 -0
  116. package/dist/internal/text.d.ts +7 -0
  117. package/dist/internal/text.js +15 -0
  118. package/dist/internal/timer.d.ts +10 -0
  119. package/dist/internal/timer.js +17 -0
  120. package/dist/internal/truncate.d.ts +10 -0
  121. package/dist/internal/truncate.js +22 -0
  122. package/dist/internal/walk.d.ts +47 -0
  123. package/dist/internal/walk.js +100 -0
  124. package/dist/is/index.d.ts +8 -0
  125. package/dist/is/index.js +8 -0
  126. package/dist/is/isArrayLike.d.ts +18 -0
  127. package/dist/is/isArrayLike.js +25 -0
  128. package/dist/is/isError.d.ts +13 -0
  129. package/dist/is/isError.js +18 -0
  130. package/dist/is/isNil.d.ts +12 -0
  131. package/dist/is/isNil.js +14 -0
  132. package/dist/is/isPlainObject.d.ts +15 -0
  133. package/dist/is/isPlainObject.js +34 -0
  134. package/dist/number/index.d.ts +7 -0
  135. package/dist/number/index.js +7 -0
  136. package/dist/number/round.d.ts +86 -0
  137. package/dist/number/round.js +130 -0
  138. package/dist/number/stats.d.ts +52 -0
  139. package/dist/number/stats.js +115 -0
  140. package/dist/object/cloneDeep.d.ts +28 -0
  141. package/dist/object/cloneDeep.js +200 -0
  142. package/dist/object/index.d.ts +14 -0
  143. package/dist/object/index.js +13 -0
  144. package/dist/object/isEqual.d.ts +64 -0
  145. package/dist/object/isEqual.js +289 -0
  146. package/dist/object/matches.d.ts +40 -0
  147. package/dist/object/matches.js +284 -0
  148. package/dist/object/merge.d.ts +66 -0
  149. package/dist/object/merge.js +272 -0
  150. package/dist/object/parsePath.d.ts +22 -0
  151. package/dist/object/parsePath.js +111 -0
  152. package/dist/object/path.d.ts +85 -0
  153. package/dist/object/path.js +208 -0
  154. package/dist/object/pick.d.ts +91 -0
  155. package/dist/object/pick.js +180 -0
  156. package/dist/object/reshape.d.ts +73 -0
  157. package/dist/object/reshape.js +144 -0
  158. package/dist/random/index.d.ts +96 -32
  159. package/dist/random/index.js +215 -50
  160. package/dist/string/case.d.ts +71 -0
  161. package/dist/string/case.js +152 -0
  162. package/dist/string/fold.d.ts +35 -0
  163. package/dist/string/fold.js +100 -0
  164. package/dist/string/index.d.ts +6 -187
  165. package/dist/string/index.js +6 -226
  166. package/dist/string/truncate.d.ts +25 -0
  167. package/dist/string/truncate.js +44 -0
  168. package/dist/string/words.d.ts +27 -0
  169. package/dist/string/words.js +241 -0
  170. package/package.json +101 -58
  171. package/dist/collections/BTree.d.ts +0 -229
  172. package/dist/collections/BTree.js +0 -1165
  173. package/dist/collections/Heap.d.ts +0 -69
  174. package/dist/collections/Heap.js +0 -181
  175. package/dist/collections/LRUCache.d.ts +0 -80
  176. package/dist/collections/LRUCache.js +0 -126
  177. package/dist/collections/SortedMap.d.ts +0 -92
  178. package/dist/collections/SortedMap.js +0 -131
  179. package/dist/collections/SortedSet.d.ts +0 -69
  180. package/dist/collections/SortedSet.js +0 -99
  181. package/dist/collections/SortedTree.d.ts +0 -103
  182. package/dist/collections/SortedTree.js +0 -141
  183. package/dist/collections/SplayTree.d.ts +0 -105
  184. package/dist/collections/SplayTree.js +0 -338
  185. package/dist/collections/Trie.d.ts +0 -42
  186. package/dist/collections/Trie.js +0 -104
  187. package/dist/collections/abc.d.ts +0 -152
  188. package/dist/collections/abc.js +0 -39
  189. package/dist/collections/frozenset.d.ts +0 -19
  190. package/dist/collections/frozenset.js +0 -30
  191. package/dist/functools/index.d.ts +0 -130
  192. package/dist/functools/index.js +0 -235
  193. package/dist/globals/index.d.ts +0 -285
  194. package/dist/globals/index.js +0 -463
  195. package/dist/i18n/currency.d.ts +0 -24
  196. package/dist/i18n/currency.js +0 -85
  197. package/dist/i18n/date/index.d.ts +0 -203
  198. package/dist/i18n/date/index.js +0 -531
  199. package/dist/i18n/date/utils.d.ts +0 -65
  200. package/dist/i18n/date/utils.js +0 -290
  201. package/dist/i18n/duration.d.ts +0 -112
  202. package/dist/i18n/duration.js +0 -392
  203. package/dist/i18n/format.d.ts +0 -31
  204. package/dist/i18n/format.js +0 -506
  205. package/dist/i18n/index.d.ts +0 -8
  206. package/dist/i18n/index.js +0 -8
  207. package/dist/itertools/index.d.ts +0 -255
  208. package/dist/itertools/index.js +0 -437
  209. package/dist/math/index.d.ts +0 -96
  210. package/dist/math/index.js +0 -98
  211. package/dist/mod.d.ts +0 -1
  212. package/dist/mod.js +0 -1
  213. package/dist/operators/index.d.ts +0 -152
  214. package/dist/operators/index.js +0 -305
  215. package/dist/types.d.ts +0 -19
  216. package/dist/types.js +0 -1
@@ -1,69 +0,0 @@
1
- import { Collection } from './abc.js';
2
- /**
3
- * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
4
- * @see {@link Comparable}
5
- * @see {@link Ordered}
6
- * @template K, V
7
- */
8
- export declare class SortedSet<T> extends Collection {
9
- private readonly store;
10
- /**
11
- * Creates a new `SortedSet` object.
12
- * @param {Iterable<T>} [iterable] Initialize the set with entries.
13
- * @param {Comparer} [compareFn] The `compare` function to sort keys.
14
- */
15
- constructor(iterable?: Iterable<T>, compareFn?: any);
16
- /**
17
- * Inserts a new value in order in the `Set`, if the value doesn't exist.
18
- * @param {T} value
19
- * @returns {this} Returns the Set object.
20
- */
21
- add(value: T): this;
22
- /**
23
- * Returns the smallest value in the set.
24
- * @returns {?T}
25
- */
26
- min(): T | undefined;
27
- /**
28
- * Returns the largest value in the set.
29
- * @returns {?T}
30
- */
31
- max(): T | undefined;
32
- /**
33
- * Removes the value from the set and returns `true` if the value was found and removed.
34
- * @param {T} value
35
- * @returns {boolean} `true` if the value was found and removed.
36
- */
37
- delete(value: T): boolean;
38
- /**
39
- * Removes all values in the set.
40
- */
41
- clear(): void;
42
- /**
43
- * Returns the total number of elements in the set.
44
- * @returns {number}
45
- */
46
- get size(): number;
47
- /**
48
- * Check if there are no values in the set.
49
- * @returns {boolean} `true` if is empty.
50
- */
51
- empty(): boolean;
52
- /**
53
- * Returns `true` if the `value` exists.
54
- * @param {T} value
55
- * @returns {boolean} `true` if value is found, otherwise `false`.
56
- */
57
- contains(value: T): boolean;
58
- /**
59
- * Returns `true` if the `value` exists.
60
- * @param {T} value
61
- * @returns {boolean} `true` if value is found, otherwise `false`.
62
- */
63
- has(value: T): boolean;
64
- /**
65
- * Returns a new iterator of all values **in-order**.
66
- * @returns {Iterable<T>}
67
- */
68
- values(): Iterable<T>;
69
- }
@@ -1,99 +0,0 @@
1
- import { Collection } from './abc.js';
2
- import { SplayTree } from './SplayTree.js';
3
- /**
4
- * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
5
- * @see {@link Comparable}
6
- * @see {@link Ordered}
7
- * @template K, V
8
- */
9
- export class SortedSet extends Collection {
10
- store;
11
- /**
12
- * Creates a new `SortedSet` object.
13
- * @param {Iterable<T>} [iterable] Initialize the set with entries.
14
- * @param {Comparer} [compareFn] The `compare` function to sort keys.
15
- */
16
- constructor(iterable, compareFn) {
17
- super();
18
- this.store = new SplayTree(compareFn);
19
- if (iterable) {
20
- for (const key of iterable) {
21
- this.store.add(key);
22
- }
23
- }
24
- }
25
- /**
26
- * Inserts a new value in order in the `Set`, if the value doesn't exist.
27
- * @param {T} value
28
- * @returns {this} Returns the Set object.
29
- */
30
- add(value) {
31
- this.store.add(value);
32
- return this;
33
- }
34
- /**
35
- * Returns the smallest value in the set.
36
- * @returns {?T}
37
- */
38
- min() {
39
- return this.store.min();
40
- }
41
- /**
42
- * Returns the largest value in the set.
43
- * @returns {?T}
44
- */
45
- max() {
46
- return this.store.max();
47
- }
48
- /**
49
- * Removes the value from the set and returns `true` if the value was found and removed.
50
- * @param {T} value
51
- * @returns {boolean} `true` if the value was found and removed.
52
- */
53
- delete(value) {
54
- return this.store.remove(value) !== undefined;
55
- }
56
- /**
57
- * Removes all values in the set.
58
- */
59
- clear() {
60
- return this.store.clear();
61
- }
62
- /**
63
- * Returns the total number of elements in the set.
64
- * @returns {number}
65
- */
66
- get size() {
67
- return this.store.size;
68
- }
69
- /**
70
- * Check if there are no values in the set.
71
- * @returns {boolean} `true` if is empty.
72
- */
73
- empty() {
74
- return this.store.empty();
75
- }
76
- /**
77
- * Returns `true` if the `value` exists.
78
- * @param {T} value
79
- * @returns {boolean} `true` if value is found, otherwise `false`.
80
- */
81
- contains(value) {
82
- return this.store.contains(value);
83
- }
84
- /**
85
- * Returns `true` if the `value` exists.
86
- * @param {T} value
87
- * @returns {boolean} `true` if value is found, otherwise `false`.
88
- */
89
- has(value) {
90
- return this.store.contains(value);
91
- }
92
- /**
93
- * Returns a new iterator of all values **in-order**.
94
- * @returns {Iterable<T>}
95
- */
96
- values() {
97
- return this.store.keys();
98
- }
99
- }
@@ -1,103 +0,0 @@
1
- import { Comparer } from '../operators/index.js';
2
- import { Mapping } from './abc.js';
3
- /**
4
- * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
- * @see {@link Comparable}
6
- * @see {@link Ordered}
7
- * @template K, V
8
- */
9
- export declare class SortedTree<K, V> extends Mapping<K, V> {
10
- private readonly store;
11
- /**
12
- * Creates a new `SortedTree` object.
13
- * @param {Iterable<[K, V]>} [iterable] Initialize the tree with entries.
14
- * @param {Comparer} [compareFn] The `compare` function to sort keys.
15
- */
16
- constructor(iterable?: Iterable<[K, V]>, compareFn?: Comparer);
17
- /**
18
- * Adds a new `key` with a `null` value.
19
- * @param {K} key
20
- * @returns {this} Returns the Tree object.
21
- */
22
- add(key: K): this;
23
- /**
24
- * Returns the value associated with the `key` or `undefined`.
25
- * @param {K} key
26
- * @returns {?V} The key value or `undefined`.
27
- */
28
- get(key: K): V | undefined;
29
- /**
30
- * Sets the value for the given `key`.
31
- * @param {K} key
32
- * @param {V} value
33
- * @returns {this} Returns the Tree object.
34
- */
35
- set(key: K, value: V): this;
36
- /**
37
- * Returns the smallest key in the tree.
38
- * @returns {?K}
39
- */
40
- min(): K | undefined;
41
- /**
42
- * Returns the largest key in the tree.
43
- * @returns {?K}
44
- */
45
- max(): K | undefined;
46
- /**
47
- * Returns `true` if the `key` existed in the tree and was removed.
48
- * @param {K} key
49
- * @returns {boolean} `true` if key was removed, otherwise `false`.
50
- */
51
- delete(key: K): boolean;
52
- /**
53
- * Removes all key/value pairs in the tree.
54
- */
55
- clear(): void;
56
- /**
57
- * Freezes the tree which prevents adding, updating or removing any keys.
58
- * @returns {this}
59
- */
60
- freeze(): this;
61
- /**
62
- * Returns a new iterator of `[K, V]` pairs in reverse order of keys.
63
- * @returns {IterableIterator<[K, V]>}
64
- */
65
- reversed(): IterableIterator<[K, V]>;
66
- /**
67
- * Returns the total key/value pairs in the tree.
68
- * @returns {number}
69
- */
70
- get size(): number;
71
- /**
72
- * Check if there are no key/value pairs in the tree.
73
- * @returns {boolean} `true` if is empty.
74
- */
75
- empty(): boolean;
76
- /**
77
- * Returns `true` if the `key` exists in the tree.
78
- * @param {K} key
79
- * @returns {boolean} `true` if key is found, otherwise `false`.
80
- */
81
- contains(key: K): boolean;
82
- /**
83
- * Returns `true` if the `key` exists in the tree.
84
- * @param {K} key
85
- * @returns {boolean} `true` if key is found, otherwise `false`.
86
- */
87
- has(key: K): boolean;
88
- /**
89
- * Returns a new iterator of all **ordered** keys in the tree.
90
- * @returns {IterableIterator<K>}
91
- */
92
- keys(): IterableIterator<K>;
93
- /**
94
- * Returns a new iterator of all values **ordered** by their keys.
95
- * @returns {IterableIterator<V>}
96
- */
97
- values(): IterableIterator<V>;
98
- /**
99
- * Returns a new iterator of all key value pairs **ordered** by their keys.
100
- * @returns {IterableIterator<[K, V]>}
101
- */
102
- entries(): IterableIterator<[K, V]>;
103
- }
@@ -1,141 +0,0 @@
1
- import { Mapping } from './abc.js';
2
- import { BTree } from './BTree.js';
3
- /**
4
- * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
- * @see {@link Comparable}
6
- * @see {@link Ordered}
7
- * @template K, V
8
- */
9
- export class SortedTree extends Mapping {
10
- store;
11
- /**
12
- * Creates a new `SortedTree` object.
13
- * @param {Iterable<[K, V]>} [iterable] Initialize the tree with entries.
14
- * @param {Comparer} [compareFn] The `compare` function to sort keys.
15
- */
16
- constructor(iterable, compareFn) {
17
- super();
18
- this.store = new BTree(iterable, compareFn);
19
- }
20
- /**
21
- * Adds a new `key` with a `null` value.
22
- * @param {K} key
23
- * @returns {this} Returns the Tree object.
24
- */
25
- add(key) {
26
- this.store.set(key, null);
27
- return this;
28
- }
29
- /**
30
- * Returns the value associated with the `key` or `undefined`.
31
- * @param {K} key
32
- * @returns {?V} The key value or `undefined`.
33
- */
34
- get(key) {
35
- return this.store.get(key);
36
- }
37
- /**
38
- * Sets the value for the given `key`.
39
- * @param {K} key
40
- * @param {V} value
41
- * @returns {this} Returns the Tree object.
42
- */
43
- set(key, value) {
44
- this.store.set(key, value);
45
- return this;
46
- }
47
- /**
48
- * Returns the smallest key in the tree.
49
- * @returns {?K}
50
- */
51
- min() {
52
- return this.store.minKey();
53
- }
54
- /**
55
- * Returns the largest key in the tree.
56
- * @returns {?K}
57
- */
58
- max() {
59
- return this.store.maxKey();
60
- }
61
- /**
62
- * Returns `true` if the `key` existed in the tree and was removed.
63
- * @param {K} key
64
- * @returns {boolean} `true` if key was removed, otherwise `false`.
65
- */
66
- delete(key) {
67
- return this.store.remove(key);
68
- }
69
- /**
70
- * Removes all key/value pairs in the tree.
71
- */
72
- clear() {
73
- return this.store.clear();
74
- }
75
- /**
76
- * Freezes the tree which prevents adding, updating or removing any keys.
77
- * @returns {this}
78
- */
79
- freeze() {
80
- this.store.freeze();
81
- return this;
82
- }
83
- /**
84
- * Returns a new iterator of `[K, V]` pairs in reverse order of keys.
85
- * @returns {IterableIterator<[K, V]>}
86
- */
87
- reversed() {
88
- return this.store.reversed();
89
- }
90
- /**
91
- * Returns the total key/value pairs in the tree.
92
- * @returns {number}
93
- */
94
- get size() {
95
- return this.store.size;
96
- }
97
- /**
98
- * Check if there are no key/value pairs in the tree.
99
- * @returns {boolean} `true` if is empty.
100
- */
101
- empty() {
102
- return this.store.empty();
103
- }
104
- /**
105
- * Returns `true` if the `key` exists in the tree.
106
- * @param {K} key
107
- * @returns {boolean} `true` if key is found, otherwise `false`.
108
- */
109
- contains(key) {
110
- return this.store.contains(key);
111
- }
112
- /**
113
- * Returns `true` if the `key` exists in the tree.
114
- * @param {K} key
115
- * @returns {boolean} `true` if key is found, otherwise `false`.
116
- */
117
- has(key) {
118
- return this.store.contains(key);
119
- }
120
- /**
121
- * Returns a new iterator of all **ordered** keys in the tree.
122
- * @returns {IterableIterator<K>}
123
- */
124
- keys() {
125
- return this.store.keys();
126
- }
127
- /**
128
- * Returns a new iterator of all values **ordered** by their keys.
129
- * @returns {IterableIterator<V>}
130
- */
131
- values() {
132
- return this.store.values();
133
- }
134
- /**
135
- * Returns a new iterator of all key value pairs **ordered** by their keys.
136
- * @returns {IterableIterator<[K, V]>}
137
- */
138
- entries() {
139
- return this.store.entries();
140
- }
141
- }
@@ -1,105 +0,0 @@
1
- import { Comparer } from '../operators/index.js';
2
- import { Mapping } from './abc.js';
3
- /**
4
- * Base SplayTree node class.
5
- * @private
6
- */
7
- declare class Node<K = any, V = any> {
8
- key: K;
9
- value: V;
10
- left?: Node<K, V>;
11
- right?: Node<K, V>;
12
- constructor(key: K, value: V);
13
- get height(): number;
14
- }
15
- /**
16
- * A splay tree is a *self-balancing binary* search tree with the additional property that recently accessed elements are quick to access again.
17
- * Insertion, look-up and removal in O(log n) *amortized* time.
18
- * For many patterns of non-random operations splay trees can take better than logarithmic time, without requiring advance knowledge of the pattern.
19
- * @see {@link https://en.wikipedia.org/wiki/Splay_tree Splay tree}
20
- * @see {@link https://web.archive.org/web/20220930173835/http://www14.in.tum.de/personen/albers/papers/ipl02.pdf Randomized Splay Trees}
21
- * @template K, V
22
- */
23
- export declare class SplayTree<K, V = any> extends Mapping<K, V> {
24
- protected root?: Node<K, V>;
25
- protected cmp: Comparer;
26
- protected randSplay: number;
27
- protected count: number;
28
- /**
29
- * Create a new randomized Splay Tree
30
- * @param compareFn
31
- * @param p When an element is accessed, with probability `p` splay the tree. With probability `1 - p`, leave the tree as it is.
32
- */
33
- constructor(compareFn?: any, p?: number);
34
- top(): K | undefined;
35
- get size(): number;
36
- empty(): boolean;
37
- get height(): number;
38
- /**
39
- * Returns the value for `key` or `undefined` if the key is not found.
40
- * @param key The key to find.
41
- * @returns {?V} The value for the key or `undefined`.
42
- */
43
- get(key: K): V | undefined;
44
- /**
45
- * Inserts the `key` and `value` in the tree if the `key` does not exist.
46
- * @param {K} key A key which can be any comparable value
47
- * @param {V} value A value associated with the key
48
- * @returns
49
- */
50
- set(key: K, value: V): void;
51
- /**
52
- * Removes a specified key if it exists in the tree. The removed value is returned or `undefined` if not found.
53
- * @param {K} key The key to remove.
54
- * @returns {?V} The removed value associated with `key`.
55
- */
56
- remove(key: K): V | undefined;
57
- /**
58
- * Returns the minimum key in the tree or subtree.
59
- * @returns The minimum key.
60
- */
61
- min(root?: Node<K, V>): K | undefined;
62
- /**
63
- * Returns the maximum key in the tree or subtree.
64
- * @returns The maximum key.
65
- */
66
- max(root?: Node<K, V>): K | undefined;
67
- /**
68
- * Returns the largest key that is less than a given key.
69
- * @param key The given key
70
- * @returns {?K} The largest key found or `undefined`.
71
- */
72
- lowerBound(key: any): K | undefined;
73
- /**
74
- * This is the simplified top-down splaying method proposed by Sleator and Tarjan in {@link https://doi.org/10.1145%2F3828.3835 Self-Adjusting Binary Search Trees}.
75
- * @param key
76
- * @see {@link https://doi.org/10.1145%2F3828.3835 Self-Adjusting Binary Search Trees}
77
- */
78
- splay(key: any): void;
79
- add(key: K): void;
80
- /**
81
- * Returns `true` if the given key is in the tree.
82
- * @param {K} key The key to find.
83
- * @returns `true` if found.
84
- */
85
- contains(key: K): boolean;
86
- /** Alias of remove but just returns `true` instead of the deleted value. */
87
- delete(key: K): boolean;
88
- clear(): void;
89
- /**
90
- * Returns an ordered iterable of all the keys in the tree.
91
- * @returns {Iterable<K>} An iterable of keys in-order.
92
- */
93
- keys(): Iterable<K>;
94
- /**
95
- * Returns an ordered iterable of all the keys and values in the tree.
96
- * @returns {Iterable<[K,V]>} A iterable of `[key, value]` pairs sorted by key.
97
- */
98
- entries(): Iterable<[K, V]>;
99
- /**
100
- * Returns an ordered iterable of all the keys and values in the tree.
101
- * @returns {Iterable<V>} A iterable of `[key, value]` pairs sorted by key.
102
- */
103
- values(): Iterable<V>;
104
- }
105
- export {};