min-heap-typed 1.38.0 → 1.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/binary-tree/avl-tree.d.ts +100 -0
- package/dist/data-structures/binary-tree/avl-tree.js +341 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +144 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +261 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +409 -0
- package/dist/data-structures/binary-tree/binary-tree.js +1065 -0
- package/dist/data-structures/binary-tree/bst.d.ts +167 -0
- package/dist/data-structures/binary-tree/bst.js +512 -0
- package/dist/data-structures/binary-tree/index.d.ts +7 -0
- package/dist/data-structures/binary-tree/index.js +23 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
- package/dist/data-structures/binary-tree/rb-tree.js +27 -0
- package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
- package/dist/data-structures/binary-tree/segment-tree.js +228 -0
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +122 -0
- package/dist/data-structures/binary-tree/tree-multiset.js +351 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
- package/dist/data-structures/graph/abstract-graph.js +923 -0
- package/dist/data-structures/graph/directed-graph.d.ts +200 -0
- package/dist/data-structures/graph/directed-graph.js +422 -0
- package/dist/data-structures/graph/index.d.ts +4 -0
- package/dist/data-structures/graph/index.js +20 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
- package/dist/data-structures/graph/undirected-graph.js +252 -0
- package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
- package/dist/data-structures/hash/coordinate-map.js +65 -0
- package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
- package/dist/data-structures/hash/coordinate-set.js +55 -0
- package/dist/data-structures/hash/hash-map.d.ts +56 -0
- package/dist/data-structures/hash/hash-map.js +171 -0
- package/dist/data-structures/hash/hash-table.d.ts +106 -0
- package/dist/data-structures/hash/hash-table.js +245 -0
- package/dist/data-structures/hash/index.d.ts +6 -0
- package/dist/data-structures/hash/index.js +22 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -0
- package/dist/data-structures/hash/tree-map.js +6 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -0
- package/dist/data-structures/hash/tree-set.js +6 -0
- package/dist/data-structures/heap/heap.d.ts +224 -0
- package/dist/data-structures/heap/heap.js +497 -0
- package/dist/data-structures/heap/index.d.ts +3 -0
- package/dist/data-structures/heap/index.js +19 -0
- package/dist/data-structures/heap/max-heap.d.ts +12 -0
- package/dist/data-structures/heap/max-heap.js +24 -0
- package/dist/data-structures/heap/min-heap.d.ts +12 -0
- package/dist/data-structures/heap/min-heap.js +24 -0
- package/dist/data-structures/index.d.ts +11 -0
- package/dist/data-structures/index.js +27 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +583 -0
- package/dist/data-structures/linked-list/index.d.ts +3 -0
- package/dist/data-structures/linked-list/index.js +19 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +448 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +142 -0
- package/dist/data-structures/matrix/index.d.ts +4 -0
- package/dist/data-structures/matrix/index.js +20 -0
- package/dist/data-structures/matrix/matrix.d.ts +21 -0
- package/dist/data-structures/matrix/matrix.js +28 -0
- package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
- package/dist/data-structures/matrix/matrix2d.js +203 -0
- package/dist/data-structures/matrix/navigator.d.ts +52 -0
- package/dist/data-structures/matrix/navigator.js +106 -0
- package/dist/data-structures/matrix/vector2d.d.ts +201 -0
- package/dist/data-structures/matrix/vector2d.js +291 -0
- package/dist/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/data-structures/priority-queue/index.js +19 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +24 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +24 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/priority-queue.js +17 -0
- package/dist/data-structures/queue/deque.d.ts +165 -0
- package/dist/data-structures/queue/deque.js +276 -0
- package/dist/data-structures/queue/index.d.ts +2 -0
- package/dist/data-structures/queue/index.js +18 -0
- package/dist/data-structures/queue/queue.d.ts +107 -0
- package/dist/data-structures/queue/queue.js +170 -0
- package/dist/data-structures/stack/index.d.ts +1 -0
- package/dist/data-structures/stack/index.js +17 -0
- package/dist/data-structures/stack/stack.d.ts +63 -0
- package/dist/data-structures/stack/stack.js +91 -0
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/data-structures/tree/tree.js +58 -0
- package/dist/data-structures/trie/index.d.ts +1 -0
- package/dist/data-structures/trie/index.js +17 -0
- package/dist/data-structures/trie/trie.d.ts +84 -0
- package/dist/data-structures/trie/trie.js +268 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/interfaces/binary-tree.d.ts +7 -0
- package/dist/interfaces/binary-tree.js +2 -0
- package/dist/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/interfaces/doubly-linked-list.js +2 -0
- package/dist/interfaces/graph.d.ts +5 -0
- package/dist/interfaces/graph.js +2 -0
- package/dist/interfaces/heap.d.ts +1 -0
- package/dist/interfaces/heap.js +2 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +24 -0
- package/dist/interfaces/navigator.d.ts +1 -0
- package/dist/interfaces/navigator.js +2 -0
- package/dist/interfaces/priority-queue.d.ts +1 -0
- package/dist/interfaces/priority-queue.js +2 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/segment-tree.js +2 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +31 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
- package/dist/types/data-structures/binary-tree/bst.js +2 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/index.js +22 -0
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
- package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
- package/dist/types/data-structures/graph/abstract-graph.js +2 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/graph/directed-graph.js +9 -0
- package/dist/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/data-structures/graph/index.js +19 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/map-graph.js +2 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/undirected-graph.js +2 -0
- package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-map.js +2 -0
- package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-set.js +2 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-map.js +2 -0
- package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-table.js +2 -0
- package/dist/types/data-structures/hash/index.d.ts +1 -0
- package/dist/types/data-structures/hash/index.js +2 -0
- package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-map.js +2 -0
- package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-set.js +2 -0
- package/dist/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/data-structures/heap/heap.js +2 -0
- package/dist/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/data-structures/heap/index.js +17 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/max-heap.js +2 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/min-heap.js +2 -0
- package/dist/types/data-structures/index.d.ts +11 -0
- package/dist/types/data-structures/index.js +27 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/types/data-structures/linked-list/index.js +18 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
- package/dist/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/types/data-structures/matrix/index.js +17 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix.js +2 -0
- package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix2d.js +2 -0
- package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/data-structures/matrix/navigator.js +2 -0
- package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/vector2d.js +2 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/index.js +19 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/types/data-structures/queue/deque.js +2 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/index.js +18 -0
- package/dist/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/types/data-structures/queue/queue.js +2 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/index.js +17 -0
- package/dist/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.js +2 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/index.js +17 -0
- package/dist/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/data-structures/tree/tree.js +2 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/index.js +17 -0
- package/dist/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.js +2 -0
- package/dist/types/helpers.d.ts +9 -0
- package/dist/types/helpers.js +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/utils.d.ts +20 -0
- package/dist/utils/utils.js +73 -0
- package/package.json +1 -4
- package/src/data-structures/binary-tree/avl-tree.ts +342 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +298 -0
- package/src/data-structures/binary-tree/binary-tree.ts +1141 -0
- package/src/data-structures/binary-tree/bst.ts +529 -0
- package/src/data-structures/binary-tree/index.ts +7 -0
- package/src/data-structures/binary-tree/rb-tree.ts +366 -0
- package/src/data-structures/binary-tree/segment-tree.ts +257 -0
- package/src/data-structures/binary-tree/tree-multiset.ts +374 -0
- package/src/data-structures/graph/abstract-graph.ts +1043 -0
- package/src/data-structures/graph/directed-graph.ts +469 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +134 -0
- package/src/data-structures/graph/undirected-graph.ts +273 -0
- package/src/data-structures/hash/coordinate-map.ts +67 -0
- package/src/data-structures/hash/coordinate-set.ts +56 -0
- package/src/data-structures/hash/hash-map.ts +209 -0
- package/src/data-structures/hash/hash-table.ts +280 -0
- package/src/data-structures/hash/index.ts +6 -0
- package/src/data-structures/hash/tree-map.ts +2 -0
- package/src/data-structures/hash/tree-set.ts +2 -0
- package/src/data-structures/heap/heap.ts +561 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +24 -0
- package/src/data-structures/heap/min-heap.ts +24 -0
- package/src/data-structures/index.ts +11 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
- package/src/data-structures/matrix/index.ts +4 -0
- package/src/data-structures/matrix/matrix.ts +27 -0
- package/src/data-structures/matrix/matrix2d.ts +213 -0
- package/src/data-structures/matrix/navigator.ts +121 -0
- package/src/data-structures/matrix/vector2d.ts +317 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +23 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +23 -0
- package/src/data-structures/priority-queue/priority-queue.ts +16 -0
- package/src/data-structures/queue/deque.ts +298 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +191 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +98 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +67 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +286 -0
- package/src/index.ts +3 -3
- package/src/interfaces/binary-tree.ts +10 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/graph.ts +7 -0
- package/src/interfaces/heap.ts +1 -0
- package/src/interfaces/index.ts +8 -0
- package/src/interfaces/navigator.ts +1 -0
- package/src/interfaces/priority-queue.ts +1 -0
- package/src/interfaces/segment-tree.ts +1 -0
- package/src/interfaces/singly-linked-list.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +35 -0
- package/src/types/data-structures/binary-tree/bst.ts +11 -0
- package/src/types/data-structures/binary-tree/index.ts +6 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
- package/src/types/data-structures/graph/abstract-graph.ts +11 -0
- package/src/types/data-structures/graph/directed-graph.ts +8 -0
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/map-graph.ts +1 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/coordinate-map.ts +1 -0
- package/src/types/data-structures/hash/coordinate-set.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +1 -0
- package/src/types/data-structures/hash/hash-table.ts +1 -0
- package/src/types/data-structures/hash/index.ts +1 -0
- package/src/types/data-structures/hash/tree-map.ts +1 -0
- package/src/types/data-structures/hash/tree-set.ts +1 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +11 -0
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/index.ts +2 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +1 -0
- package/src/types/data-structures/matrix/matrix2d.ts +1 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -0
- package/src/types/data-structures/matrix/vector2d.ts +1 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/data-structures/queue/deque.ts +1 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +1 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +1 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +1 -0
- package/src/types/helpers.ts +13 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils/index.ts +2 -0
- package/src/types/utils/utils.ts +6 -0
- package/src/types/utils/validate-type.ts +35 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +86 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoordinateMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* data-structure-typed
|
|
6
|
+
*
|
|
7
|
+
* @author Tyler Zeng
|
|
8
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
|
+
* @license MIT License
|
|
10
|
+
*/
|
|
11
|
+
class CoordinateMap extends Map {
|
|
12
|
+
constructor(joint) {
|
|
13
|
+
super();
|
|
14
|
+
this._joint = '_';
|
|
15
|
+
if (joint !== undefined)
|
|
16
|
+
this._joint = joint;
|
|
17
|
+
}
|
|
18
|
+
get joint() {
|
|
19
|
+
return this._joint;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
23
|
+
* key array with a specified delimiter.
|
|
24
|
+
* @param {number[]} key - The parameter "key" is an array of numbers.
|
|
25
|
+
* @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
|
|
26
|
+
* (`super.has`) with the `key` array joined together using the `_joint` property.
|
|
27
|
+
*/
|
|
28
|
+
has(key) {
|
|
29
|
+
return super.has(key.join(this._joint));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The function overrides the set method of a Map object to convert the key from an array to a string using a specified
|
|
33
|
+
* delimiter before calling the original set method.
|
|
34
|
+
* @param {number[]} key - The key parameter is an array of numbers.
|
|
35
|
+
* @param {V} value - The value parameter is the value that you want to associate with the specified key.
|
|
36
|
+
* @returns The `set` method is returning the result of calling the `set` method of the superclass
|
|
37
|
+
* (`super.set(key.join(this._joint), value)`).
|
|
38
|
+
*/
|
|
39
|
+
set(key, value) {
|
|
40
|
+
return super.set(key.join(this._joint), value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The function overrides the get method to join the key array with a specified joint and then calls the super get
|
|
44
|
+
* method.
|
|
45
|
+
* @param {number[]} key - An array of numbers
|
|
46
|
+
* @returns The code is returning the value associated with the specified key in the map.
|
|
47
|
+
*/
|
|
48
|
+
get(key) {
|
|
49
|
+
return super.get(key.join(this._joint));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The function overrides the delete method and joins the key array using a specified joint character before calling
|
|
53
|
+
* the super delete method.
|
|
54
|
+
* @param {number[]} key - An array of numbers that represents the key to be deleted.
|
|
55
|
+
* @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
|
|
56
|
+
* `key` array joined together using the `_joint` property.
|
|
57
|
+
*/
|
|
58
|
+
delete(key) {
|
|
59
|
+
return super.delete(key.join(this._joint));
|
|
60
|
+
}
|
|
61
|
+
_setJoint(v) {
|
|
62
|
+
this._joint = v;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.CoordinateMap = CoordinateMap;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
export declare class CoordinateSet extends Set<any> {
|
|
9
|
+
constructor(joint?: string);
|
|
10
|
+
protected _joint: string;
|
|
11
|
+
get joint(): string;
|
|
12
|
+
/**
|
|
13
|
+
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
14
|
+
* joining its elements with a specified separator.
|
|
15
|
+
* @param {number[]} value - The parameter "value" is an array of numbers.
|
|
16
|
+
* @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
|
|
17
|
+
* in the joined value as an argument.
|
|
18
|
+
*/
|
|
19
|
+
has(value: number[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
|
|
22
|
+
* specified delimiter before calling the parent class's "add" function.
|
|
23
|
+
* @param {number[]} value - An array of numbers
|
|
24
|
+
* @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
|
|
25
|
+
* (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
|
|
26
|
+
*/
|
|
27
|
+
add(value: number[]): this;
|
|
28
|
+
/**
|
|
29
|
+
* The function overrides the delete method and deletes an element from a Set by joining the elements of the input
|
|
30
|
+
* array with a specified joint and then calling the delete method of the parent class.
|
|
31
|
+
* @param {number[]} value - An array of numbers
|
|
32
|
+
* @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
|
|
33
|
+
* `value` array joined together using the `_joint` property.
|
|
34
|
+
*/
|
|
35
|
+
delete(value: number[]): boolean;
|
|
36
|
+
protected _setJoint(v: string): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoordinateSet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* data-structure-typed
|
|
6
|
+
*
|
|
7
|
+
* @author Tyler Zeng
|
|
8
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
|
+
* @license MIT License
|
|
10
|
+
*/
|
|
11
|
+
class CoordinateSet extends Set {
|
|
12
|
+
constructor(joint) {
|
|
13
|
+
super();
|
|
14
|
+
this._joint = '_';
|
|
15
|
+
if (joint !== undefined)
|
|
16
|
+
this._joint = joint;
|
|
17
|
+
}
|
|
18
|
+
get joint() {
|
|
19
|
+
return this._joint;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
23
|
+
* joining its elements with a specified separator.
|
|
24
|
+
* @param {number[]} value - The parameter "value" is an array of numbers.
|
|
25
|
+
* @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
|
|
26
|
+
* in the joined value as an argument.
|
|
27
|
+
*/
|
|
28
|
+
has(value) {
|
|
29
|
+
return super.has(value.join(this._joint));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
|
|
33
|
+
* specified delimiter before calling the parent class's "add" function.
|
|
34
|
+
* @param {number[]} value - An array of numbers
|
|
35
|
+
* @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
|
|
36
|
+
* (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
|
|
37
|
+
*/
|
|
38
|
+
add(value) {
|
|
39
|
+
return super.add(value.join(this._joint));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The function overrides the delete method and deletes an element from a Set by joining the elements of the input
|
|
43
|
+
* array with a specified joint and then calling the delete method of the parent class.
|
|
44
|
+
* @param {number[]} value - An array of numbers
|
|
45
|
+
* @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
|
|
46
|
+
* `value` array joined together using the `_joint` property.
|
|
47
|
+
*/
|
|
48
|
+
delete(value) {
|
|
49
|
+
return super.delete(value.join(this._joint));
|
|
50
|
+
}
|
|
51
|
+
_setJoint(v) {
|
|
52
|
+
this._joint = v;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CoordinateSet = CoordinateSet;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { HashFunction } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* data-structure-typed
|
|
4
|
+
*
|
|
5
|
+
* @author Tyler Zeng
|
|
6
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
|
+
* @license MIT License
|
|
8
|
+
*/
|
|
9
|
+
export declare class HashMap<K, V> {
|
|
10
|
+
/**
|
|
11
|
+
* The constructor initializes the properties of a hash table, including the initial capacity, load factor, capacity
|
|
12
|
+
* multiplier, size, table array, and hash function.
|
|
13
|
+
* @param [initialCapacity=16] - The initial capacity is the initial size of the hash table. It determines the number of
|
|
14
|
+
* buckets or slots available for storing key-value pairs. The default value is 16.
|
|
15
|
+
* @param [loadFactor=0.75] - The load factor is a measure of how full the hash table can be before it is resized. It is
|
|
16
|
+
* a value between 0 and 1, where 1 means the hash table is completely full and 0 means it is completely empty. When the
|
|
17
|
+
* load factor is reached, the hash table will
|
|
18
|
+
* @param [hashFn] - The `hashFn` parameter is an optional parameter that represents the hash function used to calculate
|
|
19
|
+
* the index of a key in the hash table. If a custom hash function is not provided, a default hash function is used. The
|
|
20
|
+
* default hash function converts the key to a string, calculates the sum of the
|
|
21
|
+
*/
|
|
22
|
+
constructor(initialCapacity?: number, loadFactor?: number, hashFn?: HashFunction<K>);
|
|
23
|
+
private _initialCapacity;
|
|
24
|
+
get initialCapacity(): number;
|
|
25
|
+
set initialCapacity(value: number);
|
|
26
|
+
private _loadFactor;
|
|
27
|
+
get loadFactor(): number;
|
|
28
|
+
set loadFactor(value: number);
|
|
29
|
+
private _capacityMultiplier;
|
|
30
|
+
get capacityMultiplier(): number;
|
|
31
|
+
set capacityMultiplier(value: number);
|
|
32
|
+
private _size;
|
|
33
|
+
get size(): number;
|
|
34
|
+
set size(value: number);
|
|
35
|
+
private _table;
|
|
36
|
+
get table(): Array<Array<[K, V]>>;
|
|
37
|
+
set table(value: Array<Array<[K, V]>>);
|
|
38
|
+
private _hashFn;
|
|
39
|
+
get hashFn(): HashFunction<K>;
|
|
40
|
+
set hashFn(value: HashFunction<K>);
|
|
41
|
+
set(key: K, value: V): void;
|
|
42
|
+
get(key: K): V | undefined;
|
|
43
|
+
delete(key: K): void;
|
|
44
|
+
entries(): IterableIterator<[K, V]>;
|
|
45
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
46
|
+
clear(): void;
|
|
47
|
+
isEmpty(): boolean;
|
|
48
|
+
private _hash;
|
|
49
|
+
/**
|
|
50
|
+
* The `resizeTable` function resizes the table used in a hash map by creating a new table with a specified capacity and
|
|
51
|
+
* rehashing the key-value pairs from the old table into the new table.
|
|
52
|
+
* @param {number} newCapacity - The newCapacity parameter is the desired capacity for the resized table. It represents
|
|
53
|
+
* the number of buckets that the new table should have.
|
|
54
|
+
*/
|
|
55
|
+
private resizeTable;
|
|
56
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HashMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* data-structure-typed
|
|
6
|
+
*
|
|
7
|
+
* @author Tyler Zeng
|
|
8
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
|
+
* @license MIT License
|
|
10
|
+
*/
|
|
11
|
+
class HashMap {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor initializes the properties of a hash table, including the initial capacity, load factor, capacity
|
|
14
|
+
* multiplier, size, table array, and hash function.
|
|
15
|
+
* @param [initialCapacity=16] - The initial capacity is the initial size of the hash table. It determines the number of
|
|
16
|
+
* buckets or slots available for storing key-value pairs. The default value is 16.
|
|
17
|
+
* @param [loadFactor=0.75] - The load factor is a measure of how full the hash table can be before it is resized. It is
|
|
18
|
+
* a value between 0 and 1, where 1 means the hash table is completely full and 0 means it is completely empty. When the
|
|
19
|
+
* load factor is reached, the hash table will
|
|
20
|
+
* @param [hashFn] - The `hashFn` parameter is an optional parameter that represents the hash function used to calculate
|
|
21
|
+
* the index of a key in the hash table. If a custom hash function is not provided, a default hash function is used. The
|
|
22
|
+
* default hash function converts the key to a string, calculates the sum of the
|
|
23
|
+
*/
|
|
24
|
+
constructor(initialCapacity = 16, loadFactor = 0.75, hashFn) {
|
|
25
|
+
this._initialCapacity = initialCapacity;
|
|
26
|
+
this._loadFactor = loadFactor;
|
|
27
|
+
this._capacityMultiplier = 2;
|
|
28
|
+
this._size = 0;
|
|
29
|
+
this._table = new Array(initialCapacity);
|
|
30
|
+
this._hashFn =
|
|
31
|
+
hashFn ||
|
|
32
|
+
((key) => {
|
|
33
|
+
const strKey = String(key);
|
|
34
|
+
let hash = 0;
|
|
35
|
+
for (let i = 0; i < strKey.length; i++) {
|
|
36
|
+
hash += strKey.charCodeAt(i);
|
|
37
|
+
}
|
|
38
|
+
return hash % this.table.length;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
get initialCapacity() {
|
|
42
|
+
return this._initialCapacity;
|
|
43
|
+
}
|
|
44
|
+
set initialCapacity(value) {
|
|
45
|
+
this._initialCapacity = value;
|
|
46
|
+
}
|
|
47
|
+
get loadFactor() {
|
|
48
|
+
return this._loadFactor;
|
|
49
|
+
}
|
|
50
|
+
set loadFactor(value) {
|
|
51
|
+
this._loadFactor = value;
|
|
52
|
+
}
|
|
53
|
+
get capacityMultiplier() {
|
|
54
|
+
return this._capacityMultiplier;
|
|
55
|
+
}
|
|
56
|
+
set capacityMultiplier(value) {
|
|
57
|
+
this._capacityMultiplier = value;
|
|
58
|
+
}
|
|
59
|
+
get size() {
|
|
60
|
+
return this._size;
|
|
61
|
+
}
|
|
62
|
+
set size(value) {
|
|
63
|
+
this._size = value;
|
|
64
|
+
}
|
|
65
|
+
get table() {
|
|
66
|
+
return this._table;
|
|
67
|
+
}
|
|
68
|
+
set table(value) {
|
|
69
|
+
this._table = value;
|
|
70
|
+
}
|
|
71
|
+
get hashFn() {
|
|
72
|
+
return this._hashFn;
|
|
73
|
+
}
|
|
74
|
+
set hashFn(value) {
|
|
75
|
+
this._hashFn = value;
|
|
76
|
+
}
|
|
77
|
+
set(key, value) {
|
|
78
|
+
const loadFactor = this.size / this.table.length;
|
|
79
|
+
if (loadFactor >= this.loadFactor) {
|
|
80
|
+
this.resizeTable(this.table.length * this.capacityMultiplier);
|
|
81
|
+
}
|
|
82
|
+
const index = this._hash(key);
|
|
83
|
+
if (!this.table[index]) {
|
|
84
|
+
this.table[index] = [];
|
|
85
|
+
}
|
|
86
|
+
// Check if the key already exists in the bucket
|
|
87
|
+
for (let i = 0; i < this.table[index].length; i++) {
|
|
88
|
+
if (this.table[index][i][0] === key) {
|
|
89
|
+
this.table[index][i][1] = value;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
this.table[index].push([key, value]);
|
|
94
|
+
this.size++;
|
|
95
|
+
}
|
|
96
|
+
get(key) {
|
|
97
|
+
const index = this._hash(key);
|
|
98
|
+
if (!this.table[index]) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
for (const [k, v] of this.table[index]) {
|
|
102
|
+
if (k === key) {
|
|
103
|
+
return v;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
delete(key) {
|
|
109
|
+
const index = this._hash(key);
|
|
110
|
+
if (!this.table[index]) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < this.table[index].length; i++) {
|
|
114
|
+
if (this.table[index][i][0] === key) {
|
|
115
|
+
this.table[index].splice(i, 1);
|
|
116
|
+
this.size--;
|
|
117
|
+
// Check if the table needs to be resized down
|
|
118
|
+
const loadFactor = this.size / this.table.length;
|
|
119
|
+
if (loadFactor < this.loadFactor / this.capacityMultiplier) {
|
|
120
|
+
this.resizeTable(this.table.length / this.capacityMultiplier);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
*entries() {
|
|
127
|
+
for (const bucket of this.table) {
|
|
128
|
+
if (bucket) {
|
|
129
|
+
for (const [key, value] of bucket) {
|
|
130
|
+
yield [key, value];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
[Symbol.iterator]() {
|
|
136
|
+
return this.entries();
|
|
137
|
+
}
|
|
138
|
+
clear() {
|
|
139
|
+
this.size = 0;
|
|
140
|
+
this.table = new Array(this.initialCapacity);
|
|
141
|
+
}
|
|
142
|
+
isEmpty() {
|
|
143
|
+
return this.size === 0;
|
|
144
|
+
}
|
|
145
|
+
_hash(key) {
|
|
146
|
+
return this._hashFn(key);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The `resizeTable` function resizes the table used in a hash map by creating a new table with a specified capacity and
|
|
150
|
+
* rehashing the key-value pairs from the old table into the new table.
|
|
151
|
+
* @param {number} newCapacity - The newCapacity parameter is the desired capacity for the resized table. It represents
|
|
152
|
+
* the number of buckets that the new table should have.
|
|
153
|
+
*/
|
|
154
|
+
resizeTable(newCapacity) {
|
|
155
|
+
const newTable = new Array(newCapacity);
|
|
156
|
+
for (const bucket of this._table) {
|
|
157
|
+
// Note that this is this._table
|
|
158
|
+
if (bucket) {
|
|
159
|
+
for (const [key, value] of bucket) {
|
|
160
|
+
const newIndex = this._hash(key) % newCapacity;
|
|
161
|
+
if (!newTable[newIndex]) {
|
|
162
|
+
newTable[newIndex] = [];
|
|
163
|
+
}
|
|
164
|
+
newTable[newIndex].push([key, value]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
this._table = newTable; // Again, here is this._table
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.HashMap = HashMap;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
export declare class HashTableNode<K, V> {
|
|
9
|
+
key: K;
|
|
10
|
+
val: V;
|
|
11
|
+
next: HashTableNode<K, V> | null;
|
|
12
|
+
constructor(key: K, val: V);
|
|
13
|
+
}
|
|
14
|
+
import { HashFunction } from '../../types';
|
|
15
|
+
export declare class HashTable<K, V> {
|
|
16
|
+
private static readonly DEFAULT_CAPACITY;
|
|
17
|
+
private static readonly LOAD_FACTOR;
|
|
18
|
+
constructor(capacity?: number, hashFn?: HashFunction<K>);
|
|
19
|
+
private _capacity;
|
|
20
|
+
get capacity(): number;
|
|
21
|
+
set capacity(value: number);
|
|
22
|
+
private _size;
|
|
23
|
+
get size(): number;
|
|
24
|
+
private _buckets;
|
|
25
|
+
get buckets(): Array<HashTableNode<K, V> | null>;
|
|
26
|
+
set buckets(value: Array<HashTableNode<K, V> | null>);
|
|
27
|
+
private _hashFn;
|
|
28
|
+
get hashFn(): HashFunction<K>;
|
|
29
|
+
set hashFn(value: HashFunction<K>);
|
|
30
|
+
/**
|
|
31
|
+
* The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
|
|
32
|
+
* @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
|
|
33
|
+
* table. It is of type K, which is a generic type representing the key's data type.
|
|
34
|
+
* @param {V} val - The parameter `val` represents the value that you want to associate with the given key in the hash
|
|
35
|
+
* table.
|
|
36
|
+
* @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any
|
|
37
|
+
* value.
|
|
38
|
+
*/
|
|
39
|
+
set(key: K, val: V): void;
|
|
40
|
+
/**
|
|
41
|
+
* The `get` function retrieves the value associated with a given key from a hash table.
|
|
42
|
+
* @param {K} key - The `key` parameter represents the key of the element that we want to retrieve from the data
|
|
43
|
+
* structure.
|
|
44
|
+
* @returns The method is returning the value associated with the given key if it exists in the hash table. If the key is
|
|
45
|
+
* not found, it returns `undefined`.
|
|
46
|
+
*/
|
|
47
|
+
get(key: K): V | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The delete function removes a key-value pair from a hash table.
|
|
50
|
+
* @param {K} key - The `key` parameter represents the key of the key-value pair that needs to be removed from the hash
|
|
51
|
+
* table.
|
|
52
|
+
* @returns Nothing is being returned. The `delete` method has a return type of `void`, which means it does not return
|
|
53
|
+
* any value.
|
|
54
|
+
*/
|
|
55
|
+
delete(key: K): void;
|
|
56
|
+
/**
|
|
57
|
+
* The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
|
|
58
|
+
* capacity of the data structure.
|
|
59
|
+
* @param {K} key - The `key` parameter is the input value that needs to be hashed. It can be of any type, but in this
|
|
60
|
+
* code snippet, it is checked whether the key is a string or an object. If it is a string, the `_murmurStringHashFn`
|
|
61
|
+
* function is used to
|
|
62
|
+
* @returns the hash value of the key modulo the capacity of the data structure.
|
|
63
|
+
*/
|
|
64
|
+
protected _defaultHashFn(key: K): number;
|
|
65
|
+
/**
|
|
66
|
+
* The `_multiplicativeStringHashFn` function calculates a hash value for a given string key using the multiplicative
|
|
67
|
+
* string hash function.
|
|
68
|
+
* @param {K} key - The `key` parameter is the input value for which we want to calculate the hash. It can be of any
|
|
69
|
+
* type, as it is generic (`K`). The function converts the `key` to a string using the `String()` function.
|
|
70
|
+
* @returns a number, which is the result of the multiplicative string hash function applied to the input key.
|
|
71
|
+
*/
|
|
72
|
+
protected _multiplicativeStringHashFn<K>(key: K): number;
|
|
73
|
+
/**
|
|
74
|
+
* The function `_murmurStringHashFn` calculates a hash value for a given string key using the MurmurHash algorithm.
|
|
75
|
+
* @param {K} key - The `key` parameter is the input value for which you want to calculate the hash. It can be of any
|
|
76
|
+
* type, but it will be converted to a string using the `String()` function before calculating the hash.
|
|
77
|
+
* @returns a number, which is the hash value calculated for the given key.
|
|
78
|
+
*/
|
|
79
|
+
protected _murmurStringHashFn<K>(key: K): number;
|
|
80
|
+
/**
|
|
81
|
+
* The _hash function takes a key and returns a number.
|
|
82
|
+
* @param {K} key - The parameter "key" is of type K, which represents the type of the key that will be hashed.
|
|
83
|
+
* @returns The hash function is returning a number.
|
|
84
|
+
*/
|
|
85
|
+
protected _hash(key: K): number;
|
|
86
|
+
/**
|
|
87
|
+
* The function calculates a hash value for a given string using the djb2 algorithm.
|
|
88
|
+
* @param {string} key - The `key` parameter in the `stringHash` function is a string value that represents the input for
|
|
89
|
+
* which we want to calculate the hash value.
|
|
90
|
+
* @returns a number, which is the hash value of the input string.
|
|
91
|
+
*/
|
|
92
|
+
protected _stringHash(key: string): number;
|
|
93
|
+
/**
|
|
94
|
+
* The function `_objectHash` takes a key and returns a hash value, using a custom hash function for objects.
|
|
95
|
+
* @param {K} key - The parameter "key" is of type "K", which means it can be any type. It could be a string, number,
|
|
96
|
+
* boolean, object, or any other type of value. The purpose of the objectHash function is to generate a hash value for
|
|
97
|
+
* the key, which can be used for
|
|
98
|
+
* @returns a number, which is the hash value of the key.
|
|
99
|
+
*/
|
|
100
|
+
protected _objectHash(key: K): number;
|
|
101
|
+
/**
|
|
102
|
+
* The `expand` function increases the capacity of a hash table by creating a new array of buckets with double the
|
|
103
|
+
* capacity and rehashing all the existing key-value pairs into the new buckets.
|
|
104
|
+
*/
|
|
105
|
+
protected _expand(): void;
|
|
106
|
+
}
|