atomic-fns 0.3.1 → 0.3.3-beta

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 (84) hide show
  1. package/.esdoc.json +2 -2
  2. package/README.md +62 -13
  3. package/core/collections/BTree.d.ts +229 -0
  4. package/core/collections/BTree.js +1165 -0
  5. package/core/collections/BTree.ts +1340 -0
  6. package/core/collections/Heap.d.ts +69 -0
  7. package/core/collections/Heap.js +181 -0
  8. package/core/collections/Heap.ts +189 -0
  9. package/core/collections/LRUCache.d.ts +152 -0
  10. package/core/collections/LRUCache.js +409 -0
  11. package/core/collections/LRUCache.ts +486 -0
  12. package/core/collections/SortedMap.d.ts +92 -0
  13. package/core/collections/SortedMap.js +130 -0
  14. package/core/collections/SortedMap.ts +146 -0
  15. package/core/collections/SortedSet.d.ts +69 -0
  16. package/core/collections/SortedSet.js +99 -0
  17. package/core/collections/SortedSet.ts +110 -0
  18. package/core/collections/SortedTree.d.ts +103 -0
  19. package/core/collections/SortedTree.js +141 -0
  20. package/core/collections/SortedTree.ts +160 -0
  21. package/core/collections/SplayTree.d.ts +105 -0
  22. package/core/collections/SplayTree.js +338 -0
  23. package/core/collections/SplayTree.ts +354 -0
  24. package/core/collections/abc.d.ts +152 -0
  25. package/core/collections/abc.js +39 -0
  26. package/core/collections/abc.ts +176 -0
  27. package/core/collections/deque.d.ts +110 -0
  28. package/core/collections/deque.js +285 -0
  29. package/core/collections/deque.ts +329 -0
  30. package/core/collections/frozenset.d.ts +19 -0
  31. package/core/collections/frozenset.js +33 -0
  32. package/core/collections/frozenset.ts +37 -0
  33. package/{src → core}/collections/index.d.ts +43 -162
  34. package/{src → core}/collections/index.js +59 -165
  35. package/{src → core}/collections/index.ts +64 -226
  36. package/core/collections/test.html +10 -0
  37. package/core/collections/typedArrays.d.ts +31 -0
  38. package/core/collections/typedArrays.js +143 -0
  39. package/core/collections/typedArrays.ts +163 -0
  40. package/{src → core}/functools/index.d.ts +2 -2
  41. package/{src → core}/functools/index.js +2 -2
  42. package/{src → core}/functools/index.ts +2 -2
  43. package/{src → core}/globals/index.d.ts +2 -7
  44. package/{src → core}/globals/index.js +5 -2
  45. package/{src → core}/globals/index.ts +6 -9
  46. package/{src → core}/index.d.ts +0 -1
  47. package/{src → core}/index.js +0 -1
  48. package/{src → core}/index.ts +0 -1
  49. package/{src → core}/itertools/index.d.ts +9 -7
  50. package/{src → core}/itertools/index.js +25 -9
  51. package/{src → core}/itertools/index.ts +39 -16
  52. package/{src → core}/math/index.d.ts +0 -0
  53. package/{src → core}/math/index.js +0 -0
  54. package/{src → core}/math/index.ts +0 -0
  55. package/core/operators/index.d.ts +148 -0
  56. package/core/operators/index.js +271 -0
  57. package/core/operators/index.ts +282 -0
  58. package/{src → core}/random/index.d.ts +0 -0
  59. package/{src → core}/random/index.js +0 -0
  60. package/{src → core}/random/index.ts +0 -0
  61. package/package.json +6 -6
  62. package/tests/BTree.spec.ts +143 -0
  63. package/tests/Cache.spec.ts +161 -0
  64. package/tests/Heap.spec.ts +66 -0
  65. package/tests/SortedMap.spec.ts +144 -0
  66. package/tests/SortedSet.spec.ts +84 -0
  67. package/tests/SortedTree.spec.ts +164 -0
  68. package/tests/SplayTree.spec.ts +121 -0
  69. package/tests/collections.spec.ts +1 -1
  70. package/tests/deque.spec.ts +107 -0
  71. package/tests/globals.spec.ts +2 -2
  72. package/tests/itertools.spec.ts +2 -2
  73. package/tests/math.spec.ts +1 -1
  74. package/tests/operators.spec.ts +5 -5
  75. package/tests/random.spec.ts +10 -10
  76. package/tsconfig.json +10 -10
  77. package/tsconfig.node.json +2 -2
  78. package/tsconfig.xo.json +2 -2
  79. package/src/datetime/index.d.ts +0 -6
  80. package/src/datetime/index.js +0 -6
  81. package/src/datetime/index.ts +0 -7
  82. package/src/operators/index.d.ts +0 -31
  83. package/src/operators/index.js +0 -171
  84. package/src/operators/index.ts +0 -175
@@ -0,0 +1,146 @@
1
+ import { Mapping } from './abc.js'
2
+ import { SplayTree } from './SplayTree.js'
3
+
4
+ /**
5
+ * A `SortedMap` 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.
6
+ * @see {@link Operators.compare}
7
+ * @see {@link Operators.lt}
8
+ * @template K, V
9
+ */
10
+ export class SortedMap<K, V> extends Mapping<K, V> {
11
+ private readonly store: SplayTree<K, V>
12
+
13
+ /**
14
+ * Creates a new `SortedMap` object.
15
+ * @param {Iterable<[K, V]>} [iterable] Initialize the map with entries.
16
+ * @param {Comparer} [compareFn] The `compare` function to sort keys.
17
+ */
18
+ constructor(iterable?: Iterable<[K, V]>, compareFn?) {
19
+ super()
20
+ this.store = new SplayTree(compareFn)
21
+ if (iterable) {
22
+ for (const pair of iterable) {
23
+ this.store.set(pair[0], pair[1] ?? (null as V))
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Adds a new `key` with a `null` value, if the `key` doesn't exist.
30
+ * @param {K} key
31
+ * @returns {this} Returns the Map object.
32
+ */
33
+ add(key: K) {
34
+ this.store.set(key, null as V)
35
+ return this
36
+ }
37
+
38
+ /**
39
+ * Returns the value associated with the `key` or `undefined`.
40
+ * @param {K} key
41
+ * @returns {?V} The key value or `undefined`.
42
+ */
43
+ get(key: K) {
44
+ return this.store.get(key)
45
+ }
46
+
47
+ /**
48
+ * Sets the value for the given `key`.
49
+ * @param {K} key
50
+ * @param {V} value
51
+ * @returns {this} Returns the Map object.
52
+ */
53
+ set(key: K, value: V) {
54
+ return this.store.set(key, value)
55
+ }
56
+
57
+ /**
58
+ * Returns the smallest key in the tree.
59
+ * @returns {?K}
60
+ */
61
+ min() {
62
+ return this.store.min()
63
+ }
64
+
65
+ /**
66
+ * Returns the largest key in the tree.
67
+ * @returns {?K}
68
+ */
69
+ max() {
70
+ return this.store.max()
71
+ }
72
+
73
+ /**
74
+ * Returns `true` if the `key` existed in the map and was removed.
75
+ * @param {K} key
76
+ * @returns {boolean} `true` if key was removed, otherwise `false`.
77
+ */
78
+ delete(item: K) {
79
+ return this.store.remove(item) !== undefined
80
+ }
81
+
82
+ /**
83
+ * Removes all key/value pairs in the tree.
84
+ */
85
+ clear() {
86
+ return this.store.clear()
87
+ }
88
+
89
+ /**
90
+ * Returns the total key/value pairs in the tree.
91
+ * @returns {number}
92
+ */
93
+ get size() {
94
+ return this.store.size
95
+ }
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
+ /**
106
+ * Returns `true` if the `key` exists in the map.
107
+ * @param {K} key
108
+ * @returns {boolean} `true` if key is found, otherwise `false`.
109
+ */
110
+ contains(key: K) {
111
+ return this.store.contains(key)
112
+ }
113
+
114
+ /**
115
+ * Returns `true` if the `key` exists in the map.
116
+ * @param {K} key
117
+ * @returns {boolean} `true` if key is found, otherwise `false`.
118
+ */
119
+ has(key: K) {
120
+ return this.store.contains(key)
121
+ }
122
+
123
+ /**
124
+ * Returns a new iterator of all **ordered** keys in the map.
125
+ * @returns {Iterable<K>}
126
+ */
127
+ keys() {
128
+ return this.store.keys()
129
+ }
130
+
131
+ /**
132
+ * Returns a new iterator of all values **ordered** by their keys.
133
+ * @returns {Iterable<V>}
134
+ */
135
+ values() {
136
+ return this.store.values()
137
+ }
138
+
139
+ /**
140
+ * Returns a new iterator of all key value pairs **ordered** by their keys.
141
+ * @returns {Iterable<[K, V]>}
142
+ */
143
+ entries() {
144
+ return this.store.entries()
145
+ }
146
+ }
@@ -0,0 +1,69 @@
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 Compare}
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
+ }
@@ -0,0 +1,99 @@
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 Compare}
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
+ }
@@ -0,0 +1,110 @@
1
+ import { Collection } from './abc.js'
2
+ import { SplayTree } from './SplayTree.js'
3
+
4
+ /**
5
+ * 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.
6
+ * @see {@link Compare}
7
+ * @see {@link Ordered}
8
+ * @template K, V
9
+ */
10
+ export class SortedSet<T> extends Collection {
11
+ private readonly store: SplayTree<T>
12
+ /**
13
+ * Creates a new `SortedSet` object.
14
+ * @param {Iterable<T>} [iterable] Initialize the set with entries.
15
+ * @param {Comparer} [compareFn] The `compare` function to sort keys.
16
+ */
17
+ constructor(iterable?: Iterable<T>, compareFn?) {
18
+ super()
19
+ this.store = new SplayTree(compareFn)
20
+ if (iterable) {
21
+ for (const key of iterable) {
22
+ this.store.add(key)
23
+ }
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Inserts a new value in order in the `Set`, if the value doesn't exist.
29
+ * @param {T} value
30
+ * @returns {this} Returns the Set object.
31
+ */
32
+ add(value: T) {
33
+ this.store.add(value)
34
+ return this
35
+ }
36
+
37
+ /**
38
+ * Returns the smallest value in the set.
39
+ * @returns {?T}
40
+ */
41
+ min() {
42
+ return this.store.min()
43
+ }
44
+
45
+ /**
46
+ * Returns the largest value in the set.
47
+ * @returns {?T}
48
+ */
49
+ max() {
50
+ return this.store.max()
51
+ }
52
+
53
+ /**
54
+ * Removes the value from the set and returns `true` if the value was found and removed.
55
+ * @param {T} value
56
+ * @returns {boolean} `true` if the value was found and removed.
57
+ */
58
+ delete(value: T) {
59
+ return this.store.remove(value) !== undefined
60
+ }
61
+
62
+ /**
63
+ * Removes all values in the set.
64
+ */
65
+ clear() {
66
+ return this.store.clear()
67
+ }
68
+
69
+ /**
70
+ * Returns the total number of elements in the set.
71
+ * @returns {number}
72
+ */
73
+ get size() {
74
+ return this.store.size
75
+ }
76
+
77
+ /**
78
+ * Check if there are no values in the set.
79
+ * @returns {boolean} `true` if is empty.
80
+ */
81
+ empty() {
82
+ return this.store.empty()
83
+ }
84
+
85
+ /**
86
+ * Returns `true` if the `value` exists.
87
+ * @param {T} value
88
+ * @returns {boolean} `true` if value is found, otherwise `false`.
89
+ */
90
+ contains(value: T) {
91
+ return this.store.contains(value)
92
+ }
93
+
94
+ /**
95
+ * Returns `true` if the `value` exists.
96
+ * @param {T} value
97
+ * @returns {boolean} `true` if value is found, otherwise `false`.
98
+ */
99
+ has(value: T) {
100
+ return this.store.contains(value)
101
+ }
102
+
103
+ /**
104
+ * Returns a new iterator of all values **in-order**.
105
+ * @returns {Iterable<T>}
106
+ */
107
+ values() {
108
+ return this.store.keys()
109
+ }
110
+ }
@@ -0,0 +1,103 @@
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 Compare}
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;
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 {Iterable<[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 {Iterable<K>}
91
+ */
92
+ keys(): IterableIterator<K>;
93
+ /**
94
+ * Returns a new iterator of all values **ordered** by their keys.
95
+ * @returns {Iterable<V>}
96
+ */
97
+ values(): IterableIterator<V>;
98
+ /**
99
+ * Returns a new iterator of all key value pairs **ordered** by their keys.
100
+ * @returns {Iterable<[K, V]>}
101
+ */
102
+ entries(): IterableIterator<[K, V]>;
103
+ }
@@ -0,0 +1,141 @@
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 Compare}
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 {Iterable<[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 {Iterable<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 {Iterable<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 {Iterable<[K, V]>}
137
+ */
138
+ entries() {
139
+ return this.store.entries();
140
+ }
141
+ }