@firebase/database 1.0.9 → 1.0.10
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/dist/index.cjs.js +13834 -13834
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +13834 -13834
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +13849 -13849
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +13797 -13797
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +13849 -13849
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/Database.d.ts +137 -137
- package/dist/node-esm/src/api/OnDisconnect.d.ts +110 -110
- package/dist/node-esm/src/api/Reference.d.ts +122 -122
- package/dist/node-esm/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/node-esm/src/api/ServerValue.d.ts +30 -30
- package/dist/node-esm/src/api/Transaction.d.ts +83 -83
- package/dist/node-esm/src/api/test_access.d.ts +31 -31
- package/dist/node-esm/src/api.d.ts +18 -18
- package/dist/node-esm/src/api.standalone.d.ts +30 -30
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/node-esm/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/node-esm/src/core/CompoundWrite.d.ts +81 -81
- package/dist/node-esm/src/core/PersistentConnection.d.ts +135 -135
- package/dist/node-esm/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/node-esm/src/core/Repo.d.ts +144 -144
- package/dist/node-esm/src/core/RepoInfo.d.ts +56 -56
- package/dist/node-esm/src/core/ServerActions.d.ts +52 -52
- package/dist/node-esm/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/node-esm/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/node-esm/src/core/SyncPoint.d.ts +91 -91
- package/dist/node-esm/src/core/SyncTree.d.ts +166 -166
- package/dist/node-esm/src/core/WriteTree.d.ts +205 -205
- package/dist/node-esm/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/node-esm/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/node-esm/src/core/operation/Merge.d.ts +33 -33
- package/dist/node-esm/src/core/operation/Operation.d.ts +45 -45
- package/dist/node-esm/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/node-esm/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/node-esm/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/node-esm/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/node-esm/src/core/snap/Node.d.ts +126 -126
- package/dist/node-esm/src/core/snap/childSet.d.ts +32 -32
- package/dist/node-esm/src/core/snap/comparators.d.ts +19 -19
- package/dist/node-esm/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/node-esm/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/node-esm/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/node-esm/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/node-esm/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/node-esm/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/node-esm/src/core/snap/snap.d.ts +23 -23
- package/dist/node-esm/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/node-esm/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/node-esm/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/node-esm/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/node-esm/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/node-esm/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/node-esm/src/core/storage/storage.d.ts +22 -22
- package/dist/node-esm/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/node-esm/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/node-esm/src/core/util/NextPushId.d.ts +33 -33
- package/dist/node-esm/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/node-esm/src/core/util/Path.d.ts +94 -94
- package/dist/node-esm/src/core/util/ServerValues.d.ts +56 -56
- package/dist/node-esm/src/core/util/SortedMap.d.ts +324 -324
- package/dist/node-esm/src/core/util/Tree.d.ts +105 -105
- package/dist/node-esm/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/node-esm/src/core/util/libs/parser.d.ts +32 -32
- package/dist/node-esm/src/core/util/misc.d.ts +19 -19
- package/dist/node-esm/src/core/util/util.d.ts +176 -176
- package/dist/node-esm/src/core/util/validation.d.ts +70 -70
- package/dist/node-esm/src/core/version.d.ts +23 -23
- package/dist/node-esm/src/core/view/CacheNode.d.ts +41 -41
- package/dist/node-esm/src/core/view/Change.d.ts +46 -46
- package/dist/node-esm/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/node-esm/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/node-esm/src/core/view/Event.d.ts +64 -64
- package/dist/node-esm/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/node-esm/src/core/view/EventQueue.d.ts +67 -67
- package/dist/node-esm/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/node-esm/src/core/view/QueryParams.d.ts +95 -95
- package/dist/node-esm/src/core/view/View.d.ts +59 -59
- package/dist/node-esm/src/core/view/ViewCache.d.ts +32 -32
- package/dist/node-esm/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/node-esm/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/node-esm/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/node-esm/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/node-esm/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/node-esm/src/index.d.ts +28 -28
- package/dist/node-esm/src/index.node.d.ts +17 -17
- package/dist/node-esm/src/index.standalone.d.ts +17 -17
- package/dist/node-esm/src/internal/index.d.ts +38 -38
- package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/node-esm/src/realtime/Connection.d.ts +102 -102
- package/dist/node-esm/src/realtime/Constants.d.ts +27 -27
- package/dist/node-esm/src/realtime/Transport.d.ts +58 -58
- package/dist/node-esm/src/realtime/TransportManager.d.ts +50 -50
- package/dist/node-esm/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/node-esm/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/node-esm/src/register.d.ts +1 -1
- package/dist/node-esm/test/compound_write.test.d.ts +17 -17
- package/dist/node-esm/test/connection.test.d.ts +17 -17
- package/dist/node-esm/test/deno.test.d.ts +17 -17
- package/dist/node-esm/test/exp/integration.test.d.ts +17 -17
- package/dist/node-esm/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/node-esm/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/node-esm/test/helpers/util.d.ts +34 -34
- package/dist/node-esm/test/node.test.d.ts +17 -17
- package/dist/node-esm/test/parser.test.d.ts +17 -17
- package/dist/node-esm/test/path.test.d.ts +17 -17
- package/dist/node-esm/test/pushid.test.d.ts +17 -17
- package/dist/node-esm/test/queryconstraint.test.d.ts +17 -17
- package/dist/node-esm/test/repoinfo.test.d.ts +17 -17
- package/dist/node-esm/test/sortedmap.test.d.ts +17 -17
- package/dist/node-esm/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/node-esm/test/syncpoint.test.d.ts +17 -17
- package/dist/node-esm/test/transport.test.d.ts +17 -17
- package/dist/node-esm/test/websocketconnection.test.d.ts +17 -17
- package/dist/src/api/Database.d.ts +137 -137
- package/dist/src/api/OnDisconnect.d.ts +110 -110
- package/dist/src/api/Reference.d.ts +122 -122
- package/dist/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/src/api/ServerValue.d.ts +30 -30
- package/dist/src/api/Transaction.d.ts +83 -83
- package/dist/src/api/test_access.d.ts +31 -31
- package/dist/src/api.d.ts +18 -18
- package/dist/src/api.standalone.d.ts +30 -30
- package/dist/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/src/core/CompoundWrite.d.ts +81 -81
- package/dist/src/core/PersistentConnection.d.ts +135 -135
- package/dist/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/src/core/Repo.d.ts +144 -144
- package/dist/src/core/RepoInfo.d.ts +56 -56
- package/dist/src/core/ServerActions.d.ts +52 -52
- package/dist/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/src/core/SyncPoint.d.ts +91 -91
- package/dist/src/core/SyncTree.d.ts +166 -166
- package/dist/src/core/WriteTree.d.ts +205 -205
- package/dist/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/src/core/operation/Merge.d.ts +33 -33
- package/dist/src/core/operation/Operation.d.ts +45 -45
- package/dist/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/src/core/snap/Node.d.ts +126 -126
- package/dist/src/core/snap/childSet.d.ts +32 -32
- package/dist/src/core/snap/comparators.d.ts +19 -19
- package/dist/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/src/core/snap/snap.d.ts +23 -23
- package/dist/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/src/core/storage/storage.d.ts +22 -22
- package/dist/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/src/core/util/NextPushId.d.ts +33 -33
- package/dist/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/src/core/util/Path.d.ts +94 -94
- package/dist/src/core/util/ServerValues.d.ts +56 -56
- package/dist/src/core/util/SortedMap.d.ts +324 -324
- package/dist/src/core/util/Tree.d.ts +105 -105
- package/dist/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/src/core/util/libs/parser.d.ts +32 -32
- package/dist/src/core/util/misc.d.ts +19 -19
- package/dist/src/core/util/util.d.ts +176 -176
- package/dist/src/core/util/validation.d.ts +70 -70
- package/dist/src/core/version.d.ts +23 -23
- package/dist/src/core/view/CacheNode.d.ts +41 -41
- package/dist/src/core/view/Change.d.ts +46 -46
- package/dist/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/src/core/view/Event.d.ts +64 -64
- package/dist/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/src/core/view/EventQueue.d.ts +67 -67
- package/dist/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/src/core/view/QueryParams.d.ts +95 -95
- package/dist/src/core/view/View.d.ts +59 -59
- package/dist/src/core/view/ViewCache.d.ts +32 -32
- package/dist/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/src/index.d.ts +28 -28
- package/dist/src/index.node.d.ts +17 -17
- package/dist/src/index.standalone.d.ts +17 -17
- package/dist/src/internal/index.d.ts +38 -38
- package/dist/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/src/realtime/Connection.d.ts +102 -102
- package/dist/src/realtime/Constants.d.ts +27 -27
- package/dist/src/realtime/Transport.d.ts +58 -58
- package/dist/src/realtime/TransportManager.d.ts +50 -50
- package/dist/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/src/register.d.ts +1 -1
- package/dist/test/compound_write.test.d.ts +17 -17
- package/dist/test/connection.test.d.ts +17 -17
- package/dist/test/deno.test.d.ts +17 -17
- package/dist/test/exp/integration.test.d.ts +17 -17
- package/dist/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/test/helpers/util.d.ts +34 -34
- package/dist/test/node.test.d.ts +17 -17
- package/dist/test/parser.test.d.ts +17 -17
- package/dist/test/path.test.d.ts +17 -17
- package/dist/test/pushid.test.d.ts +17 -17
- package/dist/test/queryconstraint.test.d.ts +17 -17
- package/dist/test/repoinfo.test.d.ts +17 -17
- package/dist/test/sortedmap.test.d.ts +17 -17
- package/dist/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/test/syncpoint.test.d.ts +17 -17
- package/dist/test/transport.test.d.ts +17 -17
- package/dist/test/websocketconnection.test.d.ts +17 -17
- package/package.json +8 -8
|
@@ -1,324 +1,324 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* @fileoverview Implementation of an immutable SortedMap using a Left-leaning
|
|
19
|
-
* Red-Black Tree, adapted from the implementation in Mugs
|
|
20
|
-
* (http://mads379.github.com/mugs/) by Mads Hartmann Jensen
|
|
21
|
-
* (mads379\@gmail.com).
|
|
22
|
-
*
|
|
23
|
-
* Original paper on Left-leaning Red-Black Trees:
|
|
24
|
-
* http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
|
|
25
|
-
*
|
|
26
|
-
* Invariant 1: No red node has a red child
|
|
27
|
-
* Invariant 2: Every leaf path has the same number of black nodes
|
|
28
|
-
* Invariant 3: Only the left child can be red (left leaning)
|
|
29
|
-
*/
|
|
30
|
-
export
|
|
31
|
-
/**
|
|
32
|
-
* An iterator over an LLRBNode.
|
|
33
|
-
*/
|
|
34
|
-
export declare class SortedMapIterator<K, V, T> {
|
|
35
|
-
private isReverse_;
|
|
36
|
-
private resultGenerator_;
|
|
37
|
-
private nodeStack_;
|
|
38
|
-
/**
|
|
39
|
-
* @param node - Node to iterate.
|
|
40
|
-
* @param isReverse_ - Whether or not to iterate in reverse
|
|
41
|
-
*/
|
|
42
|
-
constructor(node: LLRBNode<K, V> | LLRBEmptyNode<K, V>, startKey: K | null, comparator: Comparator<K>, isReverse_: boolean, resultGenerator_?: ((k: K, v: V) => T) | null);
|
|
43
|
-
getNext(): T;
|
|
44
|
-
hasNext(): boolean;
|
|
45
|
-
peek(): T;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Represents a node in a Left-leaning Red-Black tree.
|
|
49
|
-
*/
|
|
50
|
-
export declare class LLRBNode<K, V> {
|
|
51
|
-
key: K;
|
|
52
|
-
value: V;
|
|
53
|
-
color: boolean;
|
|
54
|
-
left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
55
|
-
right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
56
|
-
/**
|
|
57
|
-
* @param key - Key associated with this node.
|
|
58
|
-
* @param value - Value associated with this node.
|
|
59
|
-
* @param color - Whether this node is red.
|
|
60
|
-
* @param left - Left child.
|
|
61
|
-
* @param right - Right child.
|
|
62
|
-
*/
|
|
63
|
-
constructor(key: K, value: V, color: boolean | null, left?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null);
|
|
64
|
-
static RED: boolean;
|
|
65
|
-
static BLACK: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Returns a copy of the current node, optionally replacing pieces of it.
|
|
68
|
-
*
|
|
69
|
-
* @param key - New key for the node, or null.
|
|
70
|
-
* @param value - New value for the node, or null.
|
|
71
|
-
* @param color - New color for the node, or null.
|
|
72
|
-
* @param left - New left child for the node, or null.
|
|
73
|
-
* @param right - New right child for the node, or null.
|
|
74
|
-
* @returns The node copy.
|
|
75
|
-
*/
|
|
76
|
-
copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBNode<K, V>;
|
|
77
|
-
/**
|
|
78
|
-
* @returns The total number of nodes in the tree.
|
|
79
|
-
*/
|
|
80
|
-
count(): number;
|
|
81
|
-
/**
|
|
82
|
-
* @returns True if the tree is empty.
|
|
83
|
-
*/
|
|
84
|
-
isEmpty(): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Traverses the tree in key order and calls the specified action function
|
|
87
|
-
* for each node.
|
|
88
|
-
*
|
|
89
|
-
* @param action - Callback function to be called for each
|
|
90
|
-
* node. If it returns true, traversal is aborted.
|
|
91
|
-
* @returns The first truthy value returned by action, or the last falsey
|
|
92
|
-
* value returned by action
|
|
93
|
-
*/
|
|
94
|
-
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Traverses the tree in reverse key order and calls the specified action function
|
|
97
|
-
* for each node.
|
|
98
|
-
*
|
|
99
|
-
* @param action - Callback function to be called for each
|
|
100
|
-
* node. If it returns true, traversal is aborted.
|
|
101
|
-
* @returns True if traversal was aborted.
|
|
102
|
-
*/
|
|
103
|
-
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* @returns The minimum node in the tree.
|
|
106
|
-
*/
|
|
107
|
-
private min_;
|
|
108
|
-
/**
|
|
109
|
-
* @returns The maximum key in the tree.
|
|
110
|
-
*/
|
|
111
|
-
minKey(): K;
|
|
112
|
-
/**
|
|
113
|
-
* @returns The maximum key in the tree.
|
|
114
|
-
*/
|
|
115
|
-
maxKey(): K;
|
|
116
|
-
/**
|
|
117
|
-
* @param key - Key to insert.
|
|
118
|
-
* @param value - Value to insert.
|
|
119
|
-
* @param comparator - Comparator.
|
|
120
|
-
* @returns New tree, with the key/value added.
|
|
121
|
-
*/
|
|
122
|
-
insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
|
|
123
|
-
/**
|
|
124
|
-
* @returns New tree, with the minimum key removed.
|
|
125
|
-
*/
|
|
126
|
-
private removeMin_;
|
|
127
|
-
/**
|
|
128
|
-
* @param key - The key of the item to remove.
|
|
129
|
-
* @param comparator - Comparator.
|
|
130
|
-
* @returns New tree, with the specified item removed.
|
|
131
|
-
*/
|
|
132
|
-
remove(key: K, comparator: Comparator<K>): LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
133
|
-
/**
|
|
134
|
-
* @returns Whether this is a RED node.
|
|
135
|
-
*/
|
|
136
|
-
isRed_(): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* @returns New tree after performing any needed rotations.
|
|
139
|
-
*/
|
|
140
|
-
private fixUp_;
|
|
141
|
-
/**
|
|
142
|
-
* @returns New tree, after moveRedLeft.
|
|
143
|
-
*/
|
|
144
|
-
private moveRedLeft_;
|
|
145
|
-
/**
|
|
146
|
-
* @returns New tree, after moveRedRight.
|
|
147
|
-
*/
|
|
148
|
-
private moveRedRight_;
|
|
149
|
-
/**
|
|
150
|
-
* @returns New tree, after rotateLeft.
|
|
151
|
-
*/
|
|
152
|
-
private rotateLeft_;
|
|
153
|
-
/**
|
|
154
|
-
* @returns New tree, after rotateRight.
|
|
155
|
-
*/
|
|
156
|
-
private rotateRight_;
|
|
157
|
-
/**
|
|
158
|
-
* @returns Newt ree, after colorFlip.
|
|
159
|
-
*/
|
|
160
|
-
private colorFlip_;
|
|
161
|
-
/**
|
|
162
|
-
* For testing.
|
|
163
|
-
*
|
|
164
|
-
* @returns True if all is well.
|
|
165
|
-
*/
|
|
166
|
-
private checkMaxDepth_;
|
|
167
|
-
check_(): number;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Represents an empty node (a leaf node in the Red-Black Tree).
|
|
171
|
-
*/
|
|
172
|
-
export declare class LLRBEmptyNode<K, V> {
|
|
173
|
-
key: K;
|
|
174
|
-
value: V;
|
|
175
|
-
left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
176
|
-
right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
177
|
-
color: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Returns a copy of the current node.
|
|
180
|
-
*
|
|
181
|
-
* @returns The node copy.
|
|
182
|
-
*/
|
|
183
|
-
copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBEmptyNode<K, V>;
|
|
184
|
-
/**
|
|
185
|
-
* Returns a copy of the tree, with the specified key/value added.
|
|
186
|
-
*
|
|
187
|
-
* @param key - Key to be added.
|
|
188
|
-
* @param value - Value to be added.
|
|
189
|
-
* @param comparator - Comparator.
|
|
190
|
-
* @returns New tree, with item added.
|
|
191
|
-
*/
|
|
192
|
-
insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
|
|
193
|
-
/**
|
|
194
|
-
* Returns a copy of the tree, with the specified key removed.
|
|
195
|
-
*
|
|
196
|
-
* @param key - The key to remove.
|
|
197
|
-
* @param comparator - Comparator.
|
|
198
|
-
* @returns New tree, with item removed.
|
|
199
|
-
*/
|
|
200
|
-
remove(key: K, comparator: Comparator<K>): LLRBEmptyNode<K, V>;
|
|
201
|
-
/**
|
|
202
|
-
* @returns The total number of nodes in the tree.
|
|
203
|
-
*/
|
|
204
|
-
count(): number;
|
|
205
|
-
/**
|
|
206
|
-
* @returns True if the tree is empty.
|
|
207
|
-
*/
|
|
208
|
-
isEmpty(): boolean;
|
|
209
|
-
/**
|
|
210
|
-
* Traverses the tree in key order and calls the specified action function
|
|
211
|
-
* for each node.
|
|
212
|
-
*
|
|
213
|
-
* @param action - Callback function to be called for each
|
|
214
|
-
* node. If it returns true, traversal is aborted.
|
|
215
|
-
* @returns True if traversal was aborted.
|
|
216
|
-
*/
|
|
217
|
-
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Traverses the tree in reverse key order and calls the specified action function
|
|
220
|
-
* for each node.
|
|
221
|
-
*
|
|
222
|
-
* @param action - Callback function to be called for each
|
|
223
|
-
* node. If it returns true, traversal is aborted.
|
|
224
|
-
* @returns True if traversal was aborted.
|
|
225
|
-
*/
|
|
226
|
-
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
227
|
-
minKey(): null;
|
|
228
|
-
maxKey(): null;
|
|
229
|
-
check_(): number;
|
|
230
|
-
/**
|
|
231
|
-
* @returns Whether this node is red.
|
|
232
|
-
*/
|
|
233
|
-
isRed_(): boolean;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* An immutable sorted map implementation, based on a Left-leaning Red-Black
|
|
237
|
-
* tree.
|
|
238
|
-
*/
|
|
239
|
-
export declare class SortedMap<K, V> {
|
|
240
|
-
private comparator_;
|
|
241
|
-
private root_;
|
|
242
|
-
/**
|
|
243
|
-
* Always use the same empty node, to reduce memory.
|
|
244
|
-
*/
|
|
245
|
-
static EMPTY_NODE: LLRBEmptyNode<unknown, unknown>;
|
|
246
|
-
/**
|
|
247
|
-
* @param comparator_ - Key comparator.
|
|
248
|
-
* @param root_ - Optional root node for the map.
|
|
249
|
-
*/
|
|
250
|
-
constructor(comparator_: Comparator<K>, root_?: LLRBNode<K, V> | LLRBEmptyNode<K, V>);
|
|
251
|
-
/**
|
|
252
|
-
* Returns a copy of the map, with the specified key/value added or replaced.
|
|
253
|
-
* (TODO: We should perhaps rename this method to 'put')
|
|
254
|
-
*
|
|
255
|
-
* @param key - Key to be added.
|
|
256
|
-
* @param value - Value to be added.
|
|
257
|
-
* @returns New map, with item added.
|
|
258
|
-
*/
|
|
259
|
-
insert(key: K, value: V): SortedMap<K, V>;
|
|
260
|
-
/**
|
|
261
|
-
* Returns a copy of the map, with the specified key removed.
|
|
262
|
-
*
|
|
263
|
-
* @param key - The key to remove.
|
|
264
|
-
* @returns New map, with item removed.
|
|
265
|
-
*/
|
|
266
|
-
remove(key: K): SortedMap<K, V>;
|
|
267
|
-
/**
|
|
268
|
-
* Returns the value of the node with the given key, or null.
|
|
269
|
-
*
|
|
270
|
-
* @param key - The key to look up.
|
|
271
|
-
* @returns The value of the node with the given key, or null if the
|
|
272
|
-
* key doesn't exist.
|
|
273
|
-
*/
|
|
274
|
-
get(key: K): V | null;
|
|
275
|
-
/**
|
|
276
|
-
* Returns the key of the item *before* the specified key, or null if key is the first item.
|
|
277
|
-
* @param key - The key to find the predecessor of
|
|
278
|
-
* @returns The predecessor key.
|
|
279
|
-
*/
|
|
280
|
-
getPredecessorKey(key: K): K | null;
|
|
281
|
-
/**
|
|
282
|
-
* @returns True if the map is empty.
|
|
283
|
-
*/
|
|
284
|
-
isEmpty(): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* @returns The total number of nodes in the map.
|
|
287
|
-
*/
|
|
288
|
-
count(): number;
|
|
289
|
-
/**
|
|
290
|
-
* @returns The minimum key in the map.
|
|
291
|
-
*/
|
|
292
|
-
minKey(): K | null;
|
|
293
|
-
/**
|
|
294
|
-
* @returns The maximum key in the map.
|
|
295
|
-
*/
|
|
296
|
-
maxKey(): K | null;
|
|
297
|
-
/**
|
|
298
|
-
* Traverses the map in key order and calls the specified action function
|
|
299
|
-
* for each key/value pair.
|
|
300
|
-
*
|
|
301
|
-
* @param action - Callback function to be called
|
|
302
|
-
* for each key/value pair. If action returns true, traversal is aborted.
|
|
303
|
-
* @returns The first truthy value returned by action, or the last falsey
|
|
304
|
-
* value returned by action
|
|
305
|
-
*/
|
|
306
|
-
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
307
|
-
/**
|
|
308
|
-
* Traverses the map in reverse key order and calls the specified action function
|
|
309
|
-
* for each key/value pair.
|
|
310
|
-
*
|
|
311
|
-
* @param action - Callback function to be called
|
|
312
|
-
* for each key/value pair. If action returns true, traversal is aborted.
|
|
313
|
-
* @returns True if the traversal was aborted.
|
|
314
|
-
*/
|
|
315
|
-
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
316
|
-
/**
|
|
317
|
-
* Returns an iterator over the SortedMap.
|
|
318
|
-
* @returns The iterator.
|
|
319
|
-
*/
|
|
320
|
-
getIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
321
|
-
getIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
322
|
-
getReverseIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
323
|
-
getReverseIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
324
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview Implementation of an immutable SortedMap using a Left-leaning
|
|
19
|
+
* Red-Black Tree, adapted from the implementation in Mugs
|
|
20
|
+
* (http://mads379.github.com/mugs/) by Mads Hartmann Jensen
|
|
21
|
+
* (mads379\@gmail.com).
|
|
22
|
+
*
|
|
23
|
+
* Original paper on Left-leaning Red-Black Trees:
|
|
24
|
+
* http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
|
|
25
|
+
*
|
|
26
|
+
* Invariant 1: No red node has a red child
|
|
27
|
+
* Invariant 2: Every leaf path has the same number of black nodes
|
|
28
|
+
* Invariant 3: Only the left child can be red (left leaning)
|
|
29
|
+
*/
|
|
30
|
+
export type Comparator<K> = (key1: K, key2: K) => number;
|
|
31
|
+
/**
|
|
32
|
+
* An iterator over an LLRBNode.
|
|
33
|
+
*/
|
|
34
|
+
export declare class SortedMapIterator<K, V, T> {
|
|
35
|
+
private isReverse_;
|
|
36
|
+
private resultGenerator_;
|
|
37
|
+
private nodeStack_;
|
|
38
|
+
/**
|
|
39
|
+
* @param node - Node to iterate.
|
|
40
|
+
* @param isReverse_ - Whether or not to iterate in reverse
|
|
41
|
+
*/
|
|
42
|
+
constructor(node: LLRBNode<K, V> | LLRBEmptyNode<K, V>, startKey: K | null, comparator: Comparator<K>, isReverse_: boolean, resultGenerator_?: ((k: K, v: V) => T) | null);
|
|
43
|
+
getNext(): T;
|
|
44
|
+
hasNext(): boolean;
|
|
45
|
+
peek(): T;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents a node in a Left-leaning Red-Black tree.
|
|
49
|
+
*/
|
|
50
|
+
export declare class LLRBNode<K, V> {
|
|
51
|
+
key: K;
|
|
52
|
+
value: V;
|
|
53
|
+
color: boolean;
|
|
54
|
+
left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
55
|
+
right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
56
|
+
/**
|
|
57
|
+
* @param key - Key associated with this node.
|
|
58
|
+
* @param value - Value associated with this node.
|
|
59
|
+
* @param color - Whether this node is red.
|
|
60
|
+
* @param left - Left child.
|
|
61
|
+
* @param right - Right child.
|
|
62
|
+
*/
|
|
63
|
+
constructor(key: K, value: V, color: boolean | null, left?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null);
|
|
64
|
+
static RED: boolean;
|
|
65
|
+
static BLACK: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a copy of the current node, optionally replacing pieces of it.
|
|
68
|
+
*
|
|
69
|
+
* @param key - New key for the node, or null.
|
|
70
|
+
* @param value - New value for the node, or null.
|
|
71
|
+
* @param color - New color for the node, or null.
|
|
72
|
+
* @param left - New left child for the node, or null.
|
|
73
|
+
* @param right - New right child for the node, or null.
|
|
74
|
+
* @returns The node copy.
|
|
75
|
+
*/
|
|
76
|
+
copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBNode<K, V>;
|
|
77
|
+
/**
|
|
78
|
+
* @returns The total number of nodes in the tree.
|
|
79
|
+
*/
|
|
80
|
+
count(): number;
|
|
81
|
+
/**
|
|
82
|
+
* @returns True if the tree is empty.
|
|
83
|
+
*/
|
|
84
|
+
isEmpty(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Traverses the tree in key order and calls the specified action function
|
|
87
|
+
* for each node.
|
|
88
|
+
*
|
|
89
|
+
* @param action - Callback function to be called for each
|
|
90
|
+
* node. If it returns true, traversal is aborted.
|
|
91
|
+
* @returns The first truthy value returned by action, or the last falsey
|
|
92
|
+
* value returned by action
|
|
93
|
+
*/
|
|
94
|
+
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Traverses the tree in reverse key order and calls the specified action function
|
|
97
|
+
* for each node.
|
|
98
|
+
*
|
|
99
|
+
* @param action - Callback function to be called for each
|
|
100
|
+
* node. If it returns true, traversal is aborted.
|
|
101
|
+
* @returns True if traversal was aborted.
|
|
102
|
+
*/
|
|
103
|
+
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* @returns The minimum node in the tree.
|
|
106
|
+
*/
|
|
107
|
+
private min_;
|
|
108
|
+
/**
|
|
109
|
+
* @returns The maximum key in the tree.
|
|
110
|
+
*/
|
|
111
|
+
minKey(): K;
|
|
112
|
+
/**
|
|
113
|
+
* @returns The maximum key in the tree.
|
|
114
|
+
*/
|
|
115
|
+
maxKey(): K;
|
|
116
|
+
/**
|
|
117
|
+
* @param key - Key to insert.
|
|
118
|
+
* @param value - Value to insert.
|
|
119
|
+
* @param comparator - Comparator.
|
|
120
|
+
* @returns New tree, with the key/value added.
|
|
121
|
+
*/
|
|
122
|
+
insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
|
|
123
|
+
/**
|
|
124
|
+
* @returns New tree, with the minimum key removed.
|
|
125
|
+
*/
|
|
126
|
+
private removeMin_;
|
|
127
|
+
/**
|
|
128
|
+
* @param key - The key of the item to remove.
|
|
129
|
+
* @param comparator - Comparator.
|
|
130
|
+
* @returns New tree, with the specified item removed.
|
|
131
|
+
*/
|
|
132
|
+
remove(key: K, comparator: Comparator<K>): LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
133
|
+
/**
|
|
134
|
+
* @returns Whether this is a RED node.
|
|
135
|
+
*/
|
|
136
|
+
isRed_(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* @returns New tree after performing any needed rotations.
|
|
139
|
+
*/
|
|
140
|
+
private fixUp_;
|
|
141
|
+
/**
|
|
142
|
+
* @returns New tree, after moveRedLeft.
|
|
143
|
+
*/
|
|
144
|
+
private moveRedLeft_;
|
|
145
|
+
/**
|
|
146
|
+
* @returns New tree, after moveRedRight.
|
|
147
|
+
*/
|
|
148
|
+
private moveRedRight_;
|
|
149
|
+
/**
|
|
150
|
+
* @returns New tree, after rotateLeft.
|
|
151
|
+
*/
|
|
152
|
+
private rotateLeft_;
|
|
153
|
+
/**
|
|
154
|
+
* @returns New tree, after rotateRight.
|
|
155
|
+
*/
|
|
156
|
+
private rotateRight_;
|
|
157
|
+
/**
|
|
158
|
+
* @returns Newt ree, after colorFlip.
|
|
159
|
+
*/
|
|
160
|
+
private colorFlip_;
|
|
161
|
+
/**
|
|
162
|
+
* For testing.
|
|
163
|
+
*
|
|
164
|
+
* @returns True if all is well.
|
|
165
|
+
*/
|
|
166
|
+
private checkMaxDepth_;
|
|
167
|
+
check_(): number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Represents an empty node (a leaf node in the Red-Black Tree).
|
|
171
|
+
*/
|
|
172
|
+
export declare class LLRBEmptyNode<K, V> {
|
|
173
|
+
key: K;
|
|
174
|
+
value: V;
|
|
175
|
+
left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
176
|
+
right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
|
|
177
|
+
color: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Returns a copy of the current node.
|
|
180
|
+
*
|
|
181
|
+
* @returns The node copy.
|
|
182
|
+
*/
|
|
183
|
+
copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBEmptyNode<K, V>;
|
|
184
|
+
/**
|
|
185
|
+
* Returns a copy of the tree, with the specified key/value added.
|
|
186
|
+
*
|
|
187
|
+
* @param key - Key to be added.
|
|
188
|
+
* @param value - Value to be added.
|
|
189
|
+
* @param comparator - Comparator.
|
|
190
|
+
* @returns New tree, with item added.
|
|
191
|
+
*/
|
|
192
|
+
insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
|
|
193
|
+
/**
|
|
194
|
+
* Returns a copy of the tree, with the specified key removed.
|
|
195
|
+
*
|
|
196
|
+
* @param key - The key to remove.
|
|
197
|
+
* @param comparator - Comparator.
|
|
198
|
+
* @returns New tree, with item removed.
|
|
199
|
+
*/
|
|
200
|
+
remove(key: K, comparator: Comparator<K>): LLRBEmptyNode<K, V>;
|
|
201
|
+
/**
|
|
202
|
+
* @returns The total number of nodes in the tree.
|
|
203
|
+
*/
|
|
204
|
+
count(): number;
|
|
205
|
+
/**
|
|
206
|
+
* @returns True if the tree is empty.
|
|
207
|
+
*/
|
|
208
|
+
isEmpty(): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Traverses the tree in key order and calls the specified action function
|
|
211
|
+
* for each node.
|
|
212
|
+
*
|
|
213
|
+
* @param action - Callback function to be called for each
|
|
214
|
+
* node. If it returns true, traversal is aborted.
|
|
215
|
+
* @returns True if traversal was aborted.
|
|
216
|
+
*/
|
|
217
|
+
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Traverses the tree in reverse key order and calls the specified action function
|
|
220
|
+
* for each node.
|
|
221
|
+
*
|
|
222
|
+
* @param action - Callback function to be called for each
|
|
223
|
+
* node. If it returns true, traversal is aborted.
|
|
224
|
+
* @returns True if traversal was aborted.
|
|
225
|
+
*/
|
|
226
|
+
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
227
|
+
minKey(): null;
|
|
228
|
+
maxKey(): null;
|
|
229
|
+
check_(): number;
|
|
230
|
+
/**
|
|
231
|
+
* @returns Whether this node is red.
|
|
232
|
+
*/
|
|
233
|
+
isRed_(): boolean;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* An immutable sorted map implementation, based on a Left-leaning Red-Black
|
|
237
|
+
* tree.
|
|
238
|
+
*/
|
|
239
|
+
export declare class SortedMap<K, V> {
|
|
240
|
+
private comparator_;
|
|
241
|
+
private root_;
|
|
242
|
+
/**
|
|
243
|
+
* Always use the same empty node, to reduce memory.
|
|
244
|
+
*/
|
|
245
|
+
static EMPTY_NODE: LLRBEmptyNode<unknown, unknown>;
|
|
246
|
+
/**
|
|
247
|
+
* @param comparator_ - Key comparator.
|
|
248
|
+
* @param root_ - Optional root node for the map.
|
|
249
|
+
*/
|
|
250
|
+
constructor(comparator_: Comparator<K>, root_?: LLRBNode<K, V> | LLRBEmptyNode<K, V>);
|
|
251
|
+
/**
|
|
252
|
+
* Returns a copy of the map, with the specified key/value added or replaced.
|
|
253
|
+
* (TODO: We should perhaps rename this method to 'put')
|
|
254
|
+
*
|
|
255
|
+
* @param key - Key to be added.
|
|
256
|
+
* @param value - Value to be added.
|
|
257
|
+
* @returns New map, with item added.
|
|
258
|
+
*/
|
|
259
|
+
insert(key: K, value: V): SortedMap<K, V>;
|
|
260
|
+
/**
|
|
261
|
+
* Returns a copy of the map, with the specified key removed.
|
|
262
|
+
*
|
|
263
|
+
* @param key - The key to remove.
|
|
264
|
+
* @returns New map, with item removed.
|
|
265
|
+
*/
|
|
266
|
+
remove(key: K): SortedMap<K, V>;
|
|
267
|
+
/**
|
|
268
|
+
* Returns the value of the node with the given key, or null.
|
|
269
|
+
*
|
|
270
|
+
* @param key - The key to look up.
|
|
271
|
+
* @returns The value of the node with the given key, or null if the
|
|
272
|
+
* key doesn't exist.
|
|
273
|
+
*/
|
|
274
|
+
get(key: K): V | null;
|
|
275
|
+
/**
|
|
276
|
+
* Returns the key of the item *before* the specified key, or null if key is the first item.
|
|
277
|
+
* @param key - The key to find the predecessor of
|
|
278
|
+
* @returns The predecessor key.
|
|
279
|
+
*/
|
|
280
|
+
getPredecessorKey(key: K): K | null;
|
|
281
|
+
/**
|
|
282
|
+
* @returns True if the map is empty.
|
|
283
|
+
*/
|
|
284
|
+
isEmpty(): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* @returns The total number of nodes in the map.
|
|
287
|
+
*/
|
|
288
|
+
count(): number;
|
|
289
|
+
/**
|
|
290
|
+
* @returns The minimum key in the map.
|
|
291
|
+
*/
|
|
292
|
+
minKey(): K | null;
|
|
293
|
+
/**
|
|
294
|
+
* @returns The maximum key in the map.
|
|
295
|
+
*/
|
|
296
|
+
maxKey(): K | null;
|
|
297
|
+
/**
|
|
298
|
+
* Traverses the map in key order and calls the specified action function
|
|
299
|
+
* for each key/value pair.
|
|
300
|
+
*
|
|
301
|
+
* @param action - Callback function to be called
|
|
302
|
+
* for each key/value pair. If action returns true, traversal is aborted.
|
|
303
|
+
* @returns The first truthy value returned by action, or the last falsey
|
|
304
|
+
* value returned by action
|
|
305
|
+
*/
|
|
306
|
+
inorderTraversal(action: (k: K, v: V) => unknown): boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Traverses the map in reverse key order and calls the specified action function
|
|
309
|
+
* for each key/value pair.
|
|
310
|
+
*
|
|
311
|
+
* @param action - Callback function to be called
|
|
312
|
+
* for each key/value pair. If action returns true, traversal is aborted.
|
|
313
|
+
* @returns True if the traversal was aborted.
|
|
314
|
+
*/
|
|
315
|
+
reverseTraversal(action: (k: K, v: V) => void): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Returns an iterator over the SortedMap.
|
|
318
|
+
* @returns The iterator.
|
|
319
|
+
*/
|
|
320
|
+
getIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
321
|
+
getIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
322
|
+
getReverseIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
323
|
+
getReverseIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
|
|
324
|
+
}
|