data-structure-typed 1.38.0 → 1.38.1

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 (72) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +9 -9
  2. package/dist/data-structures/binary-tree/avl-tree.js +22 -22
  3. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  4. package/dist/data-structures/binary-tree/binary-tree.d.ts +31 -31
  5. package/dist/data-structures/binary-tree/binary-tree.js +32 -32
  6. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  8. package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -1
  9. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  10. package/dist/data-structures/binary-tree/tree-multiset.d.ts +9 -9
  11. package/dist/data-structures/binary-tree/tree-multiset.js +23 -23
  12. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  13. package/dist/data-structures/hash/hash-map.d.ts +25 -25
  14. package/dist/data-structures/hash/hash-map.js +59 -59
  15. package/dist/data-structures/hash/hash-map.js.map +1 -1
  16. package/dist/data-structures/hash/hash-table.d.ts +34 -34
  17. package/dist/data-structures/hash/hash-table.js +99 -99
  18. package/dist/data-structures/hash/hash-table.js.map +1 -1
  19. package/dist/data-structures/heap/heap.d.ts +66 -66
  20. package/dist/data-structures/heap/heap.js +167 -167
  21. package/dist/data-structures/heap/heap.js.map +1 -1
  22. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  23. package/dist/data-structures/linked-list/doubly-linked-list.js +3 -3
  24. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  25. package/dist/data-structures/linked-list/skip-linked-list.d.ts +17 -17
  26. package/dist/data-structures/linked-list/skip-linked-list.js +34 -34
  27. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  28. package/dist/data-structures/matrix/matrix2d.d.ts +7 -7
  29. package/dist/data-structures/matrix/matrix2d.js +9 -9
  30. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  31. package/dist/data-structures/trie/trie.d.ts +2 -2
  32. package/dist/data-structures/trie/trie.js +6 -6
  33. package/dist/data-structures/trie/trie.js.map +1 -1
  34. package/dist/types/helpers.js.map +1 -1
  35. package/lib/data-structures/binary-tree/avl-tree.d.ts +9 -9
  36. package/lib/data-structures/binary-tree/avl-tree.js +22 -22
  37. package/lib/data-structures/binary-tree/binary-tree.d.ts +31 -31
  38. package/lib/data-structures/binary-tree/binary-tree.js +32 -32
  39. package/lib/data-structures/binary-tree/rb-tree.d.ts +1 -1
  40. package/lib/data-structures/binary-tree/tree-multiset.d.ts +9 -9
  41. package/lib/data-structures/binary-tree/tree-multiset.js +23 -23
  42. package/lib/data-structures/hash/hash-map.d.ts +25 -25
  43. package/lib/data-structures/hash/hash-map.js +59 -59
  44. package/lib/data-structures/hash/hash-table.d.ts +34 -34
  45. package/lib/data-structures/hash/hash-table.js +99 -99
  46. package/lib/data-structures/heap/heap.d.ts +66 -66
  47. package/lib/data-structures/heap/heap.js +167 -167
  48. package/lib/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  49. package/lib/data-structures/linked-list/doubly-linked-list.js +3 -3
  50. package/lib/data-structures/linked-list/skip-linked-list.d.ts +17 -17
  51. package/lib/data-structures/linked-list/skip-linked-list.js +34 -34
  52. package/lib/data-structures/matrix/matrix2d.d.ts +7 -7
  53. package/lib/data-structures/matrix/matrix2d.js +9 -9
  54. package/lib/data-structures/trie/trie.d.ts +2 -2
  55. package/lib/data-structures/trie/trie.js +6 -6
  56. package/package.json +5 -5
  57. package/src/data-structures/binary-tree/avl-tree.ts +27 -27
  58. package/src/data-structures/binary-tree/binary-tree.ts +55 -55
  59. package/src/data-structures/binary-tree/bst.ts +4 -0
  60. package/src/data-structures/binary-tree/rb-tree.ts +2 -2
  61. package/src/data-structures/binary-tree/tree-multiset.ts +29 -29
  62. package/src/data-structures/hash/hash-map.ts +81 -75
  63. package/src/data-structures/hash/hash-table.ts +112 -109
  64. package/src/data-structures/heap/heap.ts +182 -181
  65. package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
  66. package/src/data-structures/linked-list/skip-linked-list.ts +45 -38
  67. package/src/data-structures/matrix/matrix2d.ts +10 -10
  68. package/src/data-structures/trie/trie.ts +9 -9
  69. package/src/types/helpers.ts +5 -1
  70. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +1 -1
  71. package/umd/bundle.min.js +1 -1
  72. package/umd/bundle.min.js.map +1 -1
@@ -49,29 +49,6 @@ class TreeMultiset extends avl_tree_1.AVLTree {
49
49
  createNode(key, val, count) {
50
50
  return new TreeMultisetNode(key, val, count);
51
51
  }
52
- /**
53
- * The function swaps the values of two nodes in a binary tree.
54
- * @param {N} srcNode - The source node that needs to be swapped with the destination node.
55
- * @param {N} destNode - The `destNode` parameter represents the destination node where the values
56
- * from `srcNode` will be swapped into.
57
- * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
58
- */
59
- _swap(srcNode, destNode) {
60
- const { key, val, count, height } = destNode;
61
- const tempNode = this.createNode(key, val, count);
62
- if (tempNode) {
63
- tempNode.height = height;
64
- destNode.key = srcNode.key;
65
- destNode.val = srcNode.val;
66
- destNode.count = srcNode.count;
67
- destNode.height = srcNode.height;
68
- srcNode.key = tempNode.key;
69
- srcNode.val = tempNode.val;
70
- srcNode.count = tempNode.count;
71
- srcNode.height = tempNode.height;
72
- }
73
- return destNode;
74
- }
75
52
  /**
76
53
  * The `add` function adds a new node to a binary search tree, updating the count if the key already
77
54
  * exists, and balancing the tree if necessary.
@@ -340,6 +317,29 @@ class TreeMultiset extends avl_tree_1.AVLTree {
340
317
  super.clear();
341
318
  this._setCount(0);
342
319
  }
320
+ /**
321
+ * The function swaps the values of two nodes in a binary tree.
322
+ * @param {N} srcNode - The source node that needs to be swapped with the destination node.
323
+ * @param {N} destNode - The `destNode` parameter represents the destination node where the values
324
+ * from `srcNode` will be swapped into.
325
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
326
+ */
327
+ _swap(srcNode, destNode) {
328
+ const { key, val, count, height } = destNode;
329
+ const tempNode = this.createNode(key, val, count);
330
+ if (tempNode) {
331
+ tempNode.height = height;
332
+ destNode.key = srcNode.key;
333
+ destNode.val = srcNode.val;
334
+ destNode.count = srcNode.count;
335
+ destNode.height = srcNode.height;
336
+ srcNode.key = tempNode.key;
337
+ srcNode.val = tempNode.val;
338
+ srcNode.count = tempNode.count;
339
+ srcNode.height = tempNode.height;
340
+ }
341
+ return destNode;
342
+ }
343
343
  /**
344
344
  * The function sets the value of the "_count" property.
345
345
  * @param {number} v - number
@@ -1 +1 @@
1
- {"version":3,"file":"tree-multiset.js","sourceRoot":"","sources":["../../../src/data-structures/binary-tree/tree-multiset.ts"],"names":[],"mappings":";;;AAQA,uCAAuF;AAEvF,yCAAgD;AAEhD,MAAa,gBAGX,SAAQ,sBAAsB;IAC9B;;;;;;;;;OASG;IACH,YAAY,GAAsB,EAAE,GAAO,EAAE,KAAK,GAAG,CAAC;QACpD,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAGF;AApBD,4CAoBC;AAED;;GAEG;AACH,MAAa,YACX,SAAQ,kBAAU;IAGlB;;;;;OAKG;IACH,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAGT,WAAM,GAAG,CAAC,CAAC;IAFnB,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;OAQG;IACM,UAAU,CAAC,GAAsB,EAAE,GAAc,EAAE,KAAc;QACxE,OAAO,IAAI,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAM,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACgB,KAAK,CAAC,OAAU,EAAE,QAAW;QAC9C,MAAM,EAAC,GA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BACL,sBAAsB,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;yBACzD;wBACD,YAAY,GAAG,sBAAsB,CAAC;qBACvC;iBACF;aACF;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC7B,uFAAuF;YACvF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;SAC/C;QAED,gBAAgB,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAC,CAAC,CAAC;QAE3D,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;SACjC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,CAAS;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAjVD,oCAiVC"}
1
+ {"version":3,"file":"tree-multiset.js","sourceRoot":"","sources":["../../../src/data-structures/binary-tree/tree-multiset.ts"],"names":[],"mappings":";;;AAQA,uCAAuF;AAEvF,yCAAgD;AAEhD,MAAa,gBAGX,SAAQ,sBAAsB;IAG9B;;;;;;;;;OASG;IACH,YAAY,GAAsB,EAAE,GAAO,EAAE,KAAK,GAAG,CAAC;QACpD,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AApBD,4CAoBC;AAED;;GAEG;AACH,MAAa,YACX,SAAQ,kBAAU;IAGlB;;;;;OAKG;IACH,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAGT,WAAM,GAAG,CAAC,CAAC;IAF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AAC;IAED;;OAEG;IACH,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACgB,KAAK,CAAC,OAAU,EAAE,QAAW;QAC9C,MAAM,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAC,GAAG,QAAQ,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAClD,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;YAEzB,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAC3B,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAC3B,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC/B,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAEjC,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;YAC3B,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;YAC3B,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;YAC/B,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;SAClC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,CAAS;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAjVD,oCAiVC"}
@@ -7,24 +7,6 @@ import { HashFunction } from '../../types';
7
7
  * @license MIT License
8
8
  */
9
9
  export declare class HashMap<K, V> {
10
- get hashFn(): HashFunction<K>;
11
- set hashFn(value: HashFunction<K>);
12
- get table(): Array<Array<[K, V]>>;
13
- set table(value: Array<Array<[K, V]>>);
14
- get capacityMultiplier(): number;
15
- set capacityMultiplier(value: number);
16
- get loadFactor(): number;
17
- set loadFactor(value: number);
18
- get initialCapacity(): number;
19
- set initialCapacity(value: number);
20
- get size(): number;
21
- set size(value: number);
22
- private _initialCapacity;
23
- private _loadFactor;
24
- private _capacityMultiplier;
25
- private _size;
26
- private _table;
27
- private _hashFn;
28
10
  /**
29
11
  * The constructor initializes the properties of a hash table, including the initial capacity, load factor, capacity
30
12
  * multiplier, size, table array, and hash function.
@@ -38,6 +20,31 @@ export declare class HashMap<K, V> {
38
20
  * default hash function converts the key to a string, calculates the sum of the
39
21
  */
40
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;
41
48
  private _hash;
42
49
  /**
43
50
  * The `resizeTable` function resizes the table used in a hash map by creating a new table with a specified capacity and
@@ -46,11 +53,4 @@ export declare class HashMap<K, V> {
46
53
  * the number of buckets that the new table should have.
47
54
  */
48
55
  private resizeTable;
49
- set(key: K, value: V): void;
50
- get(key: K): V | undefined;
51
- delete(key: K): void;
52
- entries(): IterableIterator<[K, V]>;
53
- [Symbol.iterator](): IterableIterator<[K, V]>;
54
- clear(): void;
55
- isEmpty(): boolean;
56
56
  }
@@ -9,42 +9,6 @@ exports.HashMap = void 0;
9
9
  * @license MIT License
10
10
  */
11
11
  class HashMap {
12
- get hashFn() {
13
- return this._hashFn;
14
- }
15
- set hashFn(value) {
16
- this._hashFn = value;
17
- }
18
- get table() {
19
- return this._table;
20
- }
21
- set table(value) {
22
- this._table = value;
23
- }
24
- get capacityMultiplier() {
25
- return this._capacityMultiplier;
26
- }
27
- set capacityMultiplier(value) {
28
- this._capacityMultiplier = value;
29
- }
30
- get loadFactor() {
31
- return this._loadFactor;
32
- }
33
- set loadFactor(value) {
34
- this._loadFactor = value;
35
- }
36
- get initialCapacity() {
37
- return this._initialCapacity;
38
- }
39
- set initialCapacity(value) {
40
- this._initialCapacity = value;
41
- }
42
- get size() {
43
- return this._size;
44
- }
45
- set size(value) {
46
- this._size = value;
47
- }
48
12
  /**
49
13
  * The constructor initializes the properties of a hash table, including the initial capacity, load factor, capacity
50
14
  * multiplier, size, table array, and hash function.
@@ -74,30 +38,41 @@ class HashMap {
74
38
  return hash % this.table.length;
75
39
  });
76
40
  }
77
- _hash(key) {
78
- return this._hashFn(key);
41
+ get initialCapacity() {
42
+ return this._initialCapacity;
79
43
  }
80
- /**
81
- * The `resizeTable` function resizes the table used in a hash map by creating a new table with a specified capacity and
82
- * rehashing the key-value pairs from the old table into the new table.
83
- * @param {number} newCapacity - The newCapacity parameter is the desired capacity for the resized table. It represents
84
- * the number of buckets that the new table should have.
85
- */
86
- resizeTable(newCapacity) {
87
- const newTable = new Array(newCapacity);
88
- for (const bucket of this._table) {
89
- // Note that this is this._table
90
- if (bucket) {
91
- for (const [key, value] of bucket) {
92
- const newIndex = this._hash(key) % newCapacity;
93
- if (!newTable[newIndex]) {
94
- newTable[newIndex] = [];
95
- }
96
- newTable[newIndex].push([key, value]);
97
- }
98
- }
99
- }
100
- this._table = newTable; // Again, here is this._table
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;
101
76
  }
102
77
  set(key, value) {
103
78
  const loadFactor = this.size / this.table.length;
@@ -167,6 +142,31 @@ class HashMap {
167
142
  isEmpty() {
168
143
  return this.size === 0;
169
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
170
  }
171
171
  exports.HashMap = HashMap;
172
172
  //# sourceMappingURL=hash-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,MAAa,OAAO;IAClB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,KAAsB;Q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,EAAE;gBACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE;oBACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;oBAC/C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;wBACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;qBACzB;oBACD,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;iBACvC;aACF;SACF;QACD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,6BAA6B;IACvD,CAAC;CACF;AAvMD,0BAuMC"}
@@ -13,19 +13,46 @@ export declare class HashTableNode<K, V> {
13
13
  }
14
14
  import { HashFunction } from '../../types';
15
15
  export declare class HashTable<K, V> {
16
- get hashFn(): HashFunction<K>;
17
- set hashFn(value: HashFunction<K>);
18
- get buckets(): Array<HashTableNode<K, V> | null>;
19
- set buckets(value: Array<HashTableNode<K, V> | null>);
20
- get capacity(): number;
21
- set capacity(value: number);
22
16
  private static readonly DEFAULT_CAPACITY;
23
17
  private static readonly LOAD_FACTOR;
18
+ constructor(capacity?: number, hashFn?: HashFunction<K>);
24
19
  private _capacity;
20
+ get capacity(): number;
21
+ set capacity(value: number);
25
22
  private _size;
23
+ get size(): number;
26
24
  private _buckets;
25
+ get buckets(): Array<HashTableNode<K, V> | null>;
26
+ set buckets(value: Array<HashTableNode<K, V> | null>);
27
27
  private _hashFn;
28
- constructor(capacity?: number, hashFn?: HashFunction<K>);
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;
29
56
  /**
30
57
  * The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
31
58
  * capacity of the data structure.
@@ -71,36 +98,9 @@ export declare class HashTable<K, V> {
71
98
  * @returns a number, which is the hash value of the key.
72
99
  */
73
100
  protected _objectHash(key: K): number;
74
- /**
75
- * The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
76
- * @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
77
- * table. It is of type K, which is a generic type representing the key's data type.
78
- * @param {V} val - The parameter `val` represents the value that you want to associate with the given key in the hash
79
- * table.
80
- * @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any
81
- * value.
82
- */
83
- set(key: K, val: V): void;
84
- /**
85
- * The `get` function retrieves the value associated with a given key from a hash table.
86
- * @param {K} key - The `key` parameter represents the key of the element that we want to retrieve from the data
87
- * structure.
88
- * @returns The method is returning the value associated with the given key if it exists in the hash table. If the key is
89
- * not found, it returns `undefined`.
90
- */
91
- get(key: K): V | undefined;
92
- /**
93
- * The delete function removes a key-value pair from a hash table.
94
- * @param {K} key - The `key` parameter represents the key of the key-value pair that needs to be removed from the hash
95
- * table.
96
- * @returns Nothing is being returned. The `delete` method has a return type of `void`, which means it does not return
97
- * any value.
98
- */
99
- delete(key: K): void;
100
101
  /**
101
102
  * The `expand` function increases the capacity of a hash table by creating a new array of buckets with double the
102
103
  * capacity and rehashing all the existing key-value pairs into the new buckets.
103
104
  */
104
105
  protected _expand(): void;
105
- get size(): number;
106
106
  }
@@ -17,113 +17,32 @@ class HashTableNode {
17
17
  }
18
18
  exports.HashTableNode = HashTableNode;
19
19
  class HashTable {
20
- get hashFn() {
21
- return this._hashFn;
22
- }
23
- set hashFn(value) {
24
- this._hashFn = value;
25
- }
26
- get buckets() {
27
- return this._buckets;
28
- }
29
- set buckets(value) {
30
- this._buckets = value;
31
- }
32
- get capacity() {
33
- return this._capacity;
34
- }
35
- set capacity(value) {
36
- this._capacity = value;
37
- }
38
20
  constructor(capacity = HashTable.DEFAULT_CAPACITY, hashFn) {
39
21
  this._hashFn = hashFn || this._defaultHashFn;
40
22
  this._capacity = Math.max(capacity, HashTable.DEFAULT_CAPACITY);
41
23
  this._size = 0;
42
24
  this._buckets = new Array(this._capacity).fill(null);
43
25
  }
44
- /**
45
- * The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
46
- * capacity of the data structure.
47
- * @param {K} key - The `key` parameter is the input value that needs to be hashed. It can be of any type, but in this
48
- * code snippet, it is checked whether the key is a string or an object. If it is a string, the `_murmurStringHashFn`
49
- * function is used to
50
- * @returns the hash value of the key modulo the capacity of the data structure.
51
- */
52
- _defaultHashFn(key) {
53
- // Can be replaced with other hash functions as needed
54
- const hashValue = typeof key === 'string' ? this._murmurStringHashFn(key) : this._objectHash(key);
55
- return hashValue % this._capacity;
26
+ get capacity() {
27
+ return this._capacity;
56
28
  }
57
- /**
58
- * The `_multiplicativeStringHashFn` function calculates a hash value for a given string key using the multiplicative
59
- * string hash function.
60
- * @param {K} key - The `key` parameter is the input value for which we want to calculate the hash. It can be of any
61
- * type, as it is generic (`K`). The function converts the `key` to a string using the `String()` function.
62
- * @returns a number, which is the result of the multiplicative string hash function applied to the input key.
63
- */
64
- _multiplicativeStringHashFn(key) {
65
- const keyString = String(key);
66
- let hash = 0;
67
- for (let i = 0; i < keyString.length; i++) {
68
- const charCode = keyString.charCodeAt(i);
69
- // Some constants for adjusting the hash function
70
- const A = 0.618033988749895;
71
- const M = 1 << 30; // 2^30
72
- hash = (hash * A + charCode) % M;
73
- }
74
- return Math.abs(hash); // Take absolute value to ensure non-negative numbers
29
+ set capacity(value) {
30
+ this._capacity = value;
75
31
  }
76
- /**
77
- * The function `_murmurStringHashFn` calculates a hash value for a given string key using the MurmurHash algorithm.
78
- * @param {K} key - The `key` parameter is the input value for which you want to calculate the hash. It can be of any
79
- * type, but it will be converted to a string using the `String()` function before calculating the hash.
80
- * @returns a number, which is the hash value calculated for the given key.
81
- */
82
- _murmurStringHashFn(key) {
83
- const keyString = String(key);
84
- const seed = 0;
85
- let hash = seed;
86
- for (let i = 0; i < keyString.length; i++) {
87
- const char = keyString.charCodeAt(i);
88
- hash = (hash ^ char) * 0x5bd1e995;
89
- hash = (hash ^ (hash >>> 15)) * 0x27d4eb2d;
90
- hash = hash ^ (hash >>> 15);
91
- }
92
- return Math.abs(hash);
32
+ get size() {
33
+ return this._size;
93
34
  }
94
- /**
95
- * The _hash function takes a key and returns a number.
96
- * @param {K} key - The parameter "key" is of type K, which represents the type of the key that will be hashed.
97
- * @returns The hash function is returning a number.
98
- */
99
- _hash(key) {
100
- return this.hashFn(key);
35
+ get buckets() {
36
+ return this._buckets;
101
37
  }
102
- /**
103
- * The function calculates a hash value for a given string using the djb2 algorithm.
104
- * @param {string} key - The `key` parameter in the `stringHash` function is a string value that represents the input for
105
- * which we want to calculate the hash value.
106
- * @returns a number, which is the hash value of the input string.
107
- */
108
- _stringHash(key) {
109
- let hash = 0;
110
- for (let i = 0; i < key.length; i++) {
111
- hash = (hash * 31 + key.charCodeAt(i)) & 0xffffffff;
112
- }
113
- return hash;
38
+ set buckets(value) {
39
+ this._buckets = value;
114
40
  }
115
- /**
116
- * The function `_objectHash` takes a key and returns a hash value, using a custom hash function for objects.
117
- * @param {K} key - The parameter "key" is of type "K", which means it can be any type. It could be a string, number,
118
- * boolean, object, or any other type of value. The purpose of the objectHash function is to generate a hash value for
119
- * the key, which can be used for
120
- * @returns a number, which is the hash value of the key.
121
- */
122
- _objectHash(key) {
123
- // If the key is an object, you can write a custom hash function
124
- // For example, convert the object's properties to a string and use string hashing
125
- // This is just an example; you should write a specific object hash function as needed
126
- return this._stringHash(JSON.stringify(key));
41
+ get hashFn() {
42
+ return this._hashFn;
43
+ }
44
+ set hashFn(value) {
45
+ this._hashFn = value;
127
46
  }
128
47
  /**
129
48
  * The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
@@ -208,6 +127,90 @@ class HashTable {
208
127
  currentNode = currentNode.next;
209
128
  }
210
129
  }
130
+ /**
131
+ * The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
132
+ * capacity of the data structure.
133
+ * @param {K} key - The `key` parameter is the input value that needs to be hashed. It can be of any type, but in this
134
+ * code snippet, it is checked whether the key is a string or an object. If it is a string, the `_murmurStringHashFn`
135
+ * function is used to
136
+ * @returns the hash value of the key modulo the capacity of the data structure.
137
+ */
138
+ _defaultHashFn(key) {
139
+ // Can be replaced with other hash functions as needed
140
+ const hashValue = typeof key === 'string' ? this._murmurStringHashFn(key) : this._objectHash(key);
141
+ return hashValue % this._capacity;
142
+ }
143
+ /**
144
+ * The `_multiplicativeStringHashFn` function calculates a hash value for a given string key using the multiplicative
145
+ * string hash function.
146
+ * @param {K} key - The `key` parameter is the input value for which we want to calculate the hash. It can be of any
147
+ * type, as it is generic (`K`). The function converts the `key` to a string using the `String()` function.
148
+ * @returns a number, which is the result of the multiplicative string hash function applied to the input key.
149
+ */
150
+ _multiplicativeStringHashFn(key) {
151
+ const keyString = String(key);
152
+ let hash = 0;
153
+ for (let i = 0; i < keyString.length; i++) {
154
+ const charCode = keyString.charCodeAt(i);
155
+ // Some constants for adjusting the hash function
156
+ const A = 0.618033988749895;
157
+ const M = 1 << 30; // 2^30
158
+ hash = (hash * A + charCode) % M;
159
+ }
160
+ return Math.abs(hash); // Take absolute value to ensure non-negative numbers
161
+ }
162
+ /**
163
+ * The function `_murmurStringHashFn` calculates a hash value for a given string key using the MurmurHash algorithm.
164
+ * @param {K} key - The `key` parameter is the input value for which you want to calculate the hash. It can be of any
165
+ * type, but it will be converted to a string using the `String()` function before calculating the hash.
166
+ * @returns a number, which is the hash value calculated for the given key.
167
+ */
168
+ _murmurStringHashFn(key) {
169
+ const keyString = String(key);
170
+ const seed = 0;
171
+ let hash = seed;
172
+ for (let i = 0; i < keyString.length; i++) {
173
+ const char = keyString.charCodeAt(i);
174
+ hash = (hash ^ char) * 0x5bd1e995;
175
+ hash = (hash ^ (hash >>> 15)) * 0x27d4eb2d;
176
+ hash = hash ^ (hash >>> 15);
177
+ }
178
+ return Math.abs(hash);
179
+ }
180
+ /**
181
+ * The _hash function takes a key and returns a number.
182
+ * @param {K} key - The parameter "key" is of type K, which represents the type of the key that will be hashed.
183
+ * @returns The hash function is returning a number.
184
+ */
185
+ _hash(key) {
186
+ return this.hashFn(key);
187
+ }
188
+ /**
189
+ * The function calculates a hash value for a given string using the djb2 algorithm.
190
+ * @param {string} key - The `key` parameter in the `stringHash` function is a string value that represents the input for
191
+ * which we want to calculate the hash value.
192
+ * @returns a number, which is the hash value of the input string.
193
+ */
194
+ _stringHash(key) {
195
+ let hash = 0;
196
+ for (let i = 0; i < key.length; i++) {
197
+ hash = (hash * 31 + key.charCodeAt(i)) & 0xffffffff;
198
+ }
199
+ return hash;
200
+ }
201
+ /**
202
+ * The function `_objectHash` takes a key and returns a hash value, using a custom hash function for objects.
203
+ * @param {K} key - The parameter "key" is of type "K", which means it can be any type. It could be a string, number,
204
+ * boolean, object, or any other type of value. The purpose of the objectHash function is to generate a hash value for
205
+ * the key, which can be used for
206
+ * @returns a number, which is the hash value of the key.
207
+ */
208
+ _objectHash(key) {
209
+ // If the key is an object, you can write a custom hash function
210
+ // For example, convert the object's properties to a string and use string hashing
211
+ // This is just an example; you should write a specific object hash function as needed
212
+ return this._stringHash(JSON.stringify(key));
213
+ }
211
214
  /**
212
215
  * The `expand` function increases the capacity of a hash table by creating a new array of buckets with double the
213
216
  * capacity and rehashing all the existing key-value pairs into the new buckets.
@@ -236,9 +239,6 @@ class HashTable {
236
239
  this._buckets = newBuckets;
237
240
  this._capacity = newCapacity;
238
241
  }
239
- get size() {
240
- return this._size;
241
- }
242
242
  }
243
243
  exports.HashTable = HashTable;
244
244
  HashTable.DEFAULT_CAPACITY = 16;