data-structure-typed 1.33.5 → 1.33.7

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 (51) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +18 -25
  4. package/coverage/coverage-final.json +64 -63
  5. package/coverage/coverage-summary.json +7 -6
  6. package/dist/data-structures/binary-tree/segment-tree.js +24 -6
  7. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
  8. package/dist/data-structures/hash/hash-map.js +306 -0
  9. package/dist/data-structures/hash/hash-map.js.map +1 -0
  10. package/dist/data-structures/hash/hash-table.js +128 -38
  11. package/dist/data-structures/hash/hash-table.js.map +1 -1
  12. package/dist/data-structures/hash/index.js +1 -0
  13. package/dist/data-structures/hash/index.js.map +1 -1
  14. package/dist/data-structures/linked-list/skip-linked-list.js +122 -5
  15. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  16. package/dist/types/data-structures/hash.js +3 -0
  17. package/dist/types/data-structures/hash.js.map +1 -0
  18. package/dist/types/data-structures/index.js +1 -0
  19. package/dist/types/data-structures/index.js.map +1 -1
  20. package/docs/index.html +23 -27
  21. package/docs/modules.html +10 -4
  22. package/lib/data-structures/binary-tree/segment-tree.d.ts +4 -4
  23. package/lib/data-structures/binary-tree/segment-tree.js +30 -14
  24. package/lib/data-structures/hash/hash-map.d.ts +56 -0
  25. package/lib/data-structures/hash/hash-map.js +167 -0
  26. package/lib/data-structures/hash/hash-table.d.ts +67 -23
  27. package/lib/data-structures/hash/hash-table.js +154 -52
  28. package/lib/data-structures/hash/index.d.ts +1 -0
  29. package/lib/data-structures/hash/index.js +1 -0
  30. package/lib/data-structures/linked-list/skip-linked-list.d.ts +60 -1
  31. package/lib/data-structures/linked-list/skip-linked-list.js +136 -1
  32. package/lib/types/data-structures/hash.d.ts +1 -0
  33. package/lib/types/data-structures/hash.js +1 -0
  34. package/lib/types/data-structures/index.d.ts +1 -0
  35. package/lib/types/data-structures/index.js +1 -0
  36. package/package.json +1 -1
  37. package/src/data-structures/binary-tree/segment-tree.ts +32 -14
  38. package/src/data-structures/hash/hash-map.ts +203 -0
  39. package/src/data-structures/hash/hash-table.ts +176 -56
  40. package/src/data-structures/hash/index.ts +1 -0
  41. package/src/data-structures/linked-list/skip-linked-list.ts +166 -1
  42. package/src/types/data-structures/hash.ts +1 -0
  43. package/src/types/data-structures/index.ts +1 -0
  44. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +50 -0
  45. package/test/unit/data-structures/hash/hash-map.test.ts +104 -0
  46. package/test/unit/data-structures/hash/hash-table.test.ts +97 -10
  47. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
  48. package/test/unit/data-structures/linked-list/skip-list.test.ts +55 -0
  49. package/umd/bundle.min.js +1 -1
  50. package/umd/bundle.min.js.map +1 -1
  51. package/tsconfig.prod.json +0 -25
@@ -1,38 +1,50 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HashTable = exports.HashNode = void 0;
4
- var HashNode = (function () {
5
- function HashNode(key, val) {
14
+ exports.HashTable = exports.HashTableNode = void 0;
15
+ var HashTableNode = (function () {
16
+ function HashTableNode(key, val) {
6
17
  this.key = key;
7
18
  this.val = val;
8
19
  this.next = null;
9
20
  }
10
- return HashNode;
21
+ return HashTableNode;
11
22
  }());
12
- exports.HashNode = HashNode;
23
+ exports.HashTableNode = HashTableNode;
13
24
  var HashTable = (function () {
14
- function HashTable(capacity) {
15
- if (capacity === void 0) { capacity = 1000; }
16
- this._capacity = capacity;
25
+ function HashTable(capacity, hashFn) {
26
+ if (capacity === void 0) { capacity = HashTable.DEFAULT_CAPACITY; }
27
+ this._hashFn = hashFn || this._defaultHashFn;
28
+ this._capacity = Math.max(capacity, HashTable.DEFAULT_CAPACITY);
17
29
  this._size = 0;
18
- this._buckets = new Array(this.capacity).fill(null);
30
+ this._buckets = new Array(this._capacity).fill(null);
19
31
  }
20
- Object.defineProperty(HashTable.prototype, "buckets", {
32
+ Object.defineProperty(HashTable.prototype, "hashFn", {
21
33
  get: function () {
22
- return this._buckets;
34
+ return this._hashFn;
23
35
  },
24
36
  set: function (value) {
25
- this._buckets = value;
37
+ this._hashFn = value;
26
38
  },
27
39
  enumerable: false,
28
40
  configurable: true
29
41
  });
30
- Object.defineProperty(HashTable.prototype, "size", {
42
+ Object.defineProperty(HashTable.prototype, "buckets", {
31
43
  get: function () {
32
- return this._size;
44
+ return this._buckets;
33
45
  },
34
46
  set: function (value) {
35
- this._size = value;
47
+ this._buckets = value;
36
48
  },
37
49
  enumerable: false,
38
50
  configurable: true
@@ -47,41 +59,74 @@ var HashTable = (function () {
47
59
  enumerable: false,
48
60
  configurable: true
49
61
  });
50
- HashTable.prototype.hash = function (key) {
62
+ HashTable.prototype._defaultHashFn = function (key) {
63
+ var hashValue = typeof key === 'string' ? this._murmurStringHashFn(key) : this._objectHash(key);
64
+ return hashValue % this._capacity;
65
+ };
66
+ HashTable.prototype._multiplicativeStringHashFn = function (key) {
51
67
  var keyString = String(key);
52
68
  var hash = 0;
53
69
  for (var i = 0; i < keyString.length; i++) {
54
- hash += keyString.charCodeAt(i);
70
+ var charCode = keyString.charCodeAt(i);
71
+ var A = 0.618033988749895;
72
+ var M = 1 << 30;
73
+ hash = (hash * A + charCode) % M;
74
+ }
75
+ return Math.abs(hash);
76
+ };
77
+ HashTable.prototype._murmurStringHashFn = function (key) {
78
+ var keyString = String(key);
79
+ var seed = 0;
80
+ var hash = seed;
81
+ for (var i = 0; i < keyString.length; i++) {
82
+ var char = keyString.charCodeAt(i);
83
+ hash = (hash ^ char) * 0x5bd1e995;
84
+ hash = (hash ^ (hash >>> 15)) * 0x27d4eb2d;
85
+ hash = hash ^ (hash >>> 15);
86
+ }
87
+ return Math.abs(hash);
88
+ };
89
+ HashTable.prototype._hash = function (key) {
90
+ return this.hashFn(key);
91
+ };
92
+ HashTable.prototype._stringHash = function (key) {
93
+ var hash = 0;
94
+ for (var i = 0; i < key.length; i++) {
95
+ hash = (hash * 31 + key.charCodeAt(i)) & 0xffffffff;
55
96
  }
56
- return hash % this.capacity;
97
+ return hash;
57
98
  };
58
- HashTable.prototype.put = function (key, val) {
59
- var index = this.hash(key);
60
- var newNode = new HashNode(key, val);
61
- if (!this.buckets[index]) {
62
- this.buckets[index] = newNode;
99
+ HashTable.prototype._objectHash = function (key) {
100
+ return this._stringHash(JSON.stringify(key));
101
+ };
102
+ HashTable.prototype.set = function (key, val) {
103
+ var index = this._hash(key);
104
+ var newNode = new HashTableNode(key, val);
105
+ if (!this._buckets[index]) {
106
+ this._buckets[index] = newNode;
63
107
  }
64
108
  else {
65
- var currentNode = this.buckets[index];
66
- while (currentNode.next) {
109
+ var currentNode = this._buckets[index];
110
+ while (currentNode) {
67
111
  if (currentNode.key === key) {
68
112
  currentNode.val = val;
69
113
  return;
70
114
  }
115
+ if (!currentNode.next) {
116
+ break;
117
+ }
71
118
  currentNode = currentNode.next;
72
119
  }
73
- if (currentNode.key === key) {
74
- currentNode.val = val;
75
- }
76
- else {
77
- currentNode.next = newNode;
78
- }
120
+ currentNode.next = newNode;
121
+ }
122
+ this._size++;
123
+ if (this._size / this._capacity >= HashTable.LOAD_FACTOR) {
124
+ this._expand();
79
125
  }
80
- this.size++;
81
126
  };
82
127
  HashTable.prototype.get = function (key) {
83
- var index = this.hash(key);
84
- var currentNode = this.buckets[index];
128
+ var index = this._hash(key);
129
+ var currentNode = this._buckets[index];
85
130
  while (currentNode) {
86
131
  if (currentNode.key === key) {
87
132
  return currentNode.val;
@@ -91,8 +136,8 @@ var HashTable = (function () {
91
136
  return undefined;
92
137
  };
93
138
  HashTable.prototype.remove = function (key) {
94
- var index = this.hash(key);
95
- var currentNode = this.buckets[index];
139
+ var index = this._hash(key);
140
+ var currentNode = this._buckets[index];
96
141
  var prevNode = null;
97
142
  while (currentNode) {
98
143
  if (currentNode.key === key) {
@@ -100,15 +145,60 @@ var HashTable = (function () {
100
145
  prevNode.next = currentNode.next;
101
146
  }
102
147
  else {
103
- this.buckets[index] = currentNode.next;
148
+ this._buckets[index] = currentNode.next;
104
149
  }
105
- this.size--;
150
+ this._size--;
151
+ currentNode.next = null;
106
152
  return;
107
153
  }
108
154
  prevNode = currentNode;
109
155
  currentNode = currentNode.next;
110
156
  }
111
157
  };
158
+ HashTable.prototype._expand = function () {
159
+ var e_1, _a;
160
+ var newCapacity = this._capacity * 2;
161
+ var newBuckets = new Array(newCapacity).fill(null);
162
+ try {
163
+ for (var _b = __values(this._buckets), _c = _b.next(); !_c.done; _c = _b.next()) {
164
+ var bucket = _c.value;
165
+ var currentNode = bucket;
166
+ while (currentNode) {
167
+ var newIndex = this._hash(currentNode.key);
168
+ var newNode = new HashTableNode(currentNode.key, currentNode.val);
169
+ if (!newBuckets[newIndex]) {
170
+ newBuckets[newIndex] = newNode;
171
+ }
172
+ else {
173
+ var currentNewNode = newBuckets[newIndex];
174
+ while (currentNewNode.next) {
175
+ currentNewNode = currentNewNode.next;
176
+ }
177
+ currentNewNode.next = newNode;
178
+ }
179
+ currentNode = currentNode.next;
180
+ }
181
+ }
182
+ }
183
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
184
+ finally {
185
+ try {
186
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
187
+ }
188
+ finally { if (e_1) throw e_1.error; }
189
+ }
190
+ this._buckets = newBuckets;
191
+ this._capacity = newCapacity;
192
+ };
193
+ Object.defineProperty(HashTable.prototype, "size", {
194
+ get: function () {
195
+ return this._size;
196
+ },
197
+ enumerable: false,
198
+ configurable: true
199
+ });
200
+ HashTable.DEFAULT_CAPACITY = 16;
201
+ HashTable.LOAD_FACTOR = 0.75;
112
202
  return HashTable;
113
203
  }());
114
204
  exports.HashTable = HashTable;
@@ -1 +1 @@
1
- {"version":3,"file":"hash-table.js","sourceRoot":"","sources":["../../../src/data-structures/hash/hash-table.ts"],"names":[],"mappings":";;;AAOA;IAKE,kBAAY,GAAM,EAAE,GAAM;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACH,eAAC;AAAD,CAAC,AAVD,IAUC;AAVY,4BAAQ;AAYrB;IAkCE,mBAAY,QAAe;QAAf,yBAAA,EAAA,eAAe;QACzB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IArCD,sBAAI,8BAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;aAED,UAAY,KAAmC;YAC7C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;;;OAJA;IAMD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aAED,UAAS,KAAa;YACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAJA;IAMD,sBAAI,+BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;aAED,UAAa,KAAa;YACxB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;;;OAJA;IA4BO,wBAAI,GAAZ,UAAa,GAAM;QACjB,IAAM,SAA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AI,WAAW,GAAG,MAAM,CAAC;gBACzB,OAAO,WAAW,EAAE;oBAClB,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;oBAC7C,IAAM,OAAO,GAAG,IAAI,aAAa,CAAO,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;oBAE1E,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;wBACzB,UAAU,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;qBAChC;yBAAM;wBACL,IAAI,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAE,CAAC;wBAC3C,OAAO,cAAc,CAAC,IAAI,EAAE;4BAC1B,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC;yBACtC;wBACD,cAAc,CAAC,IAAI,GAAG,OAAO,CAAC;qBAC/B;oBACD,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;iBAChC;aACF;;;;;;;;;QAED,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC;IAC/B,CAAC;IAED,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IApOuB,0BAAgB,GAAG,EAAE,CAAC;IACtB,qBAAW,GAAG,IAAI,CAAC;IAoO7C,gBAAC;CAAA,AA9PD,IA8PC;AA9PY,8BAAS"}
@@ -20,4 +20,5 @@ __exportStar(require("./coordinate-set"), exports);
20
20
  __exportStar(require("./pair"), exports);
21
21
  __exportStar(require("./tree-map"), exports);
22
22
  __exportStar(require("./tree-set"), exports);
23
+ __exportStar(require("./hash-map"), exports);
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,mDAAiC;AACjC,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,mDAAiC;AACjC,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,6CAA2B"}
@@ -1,10 +1,127 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SkipLinkedList = void 0;
4
- var SkipLinkedList = (function () {
5
- function SkipLinkedList() {
3
+ exports.SkipList = exports.SkipListNode = void 0;
4
+ var SkipListNode = (function () {
5
+ function SkipListNode(key, value, level) {
6
+ this.key = key;
7
+ this.value = value;
8
+ this.forward = new Array(level);
6
9
  }
7
- return SkipLinkedList;
10
+ return SkipListNode;
8
11
  }());
9
- exports.SkipLinkedList = SkipLinkedList;
12
+ exports.SkipListNode = SkipListNode;
13
+ var SkipList = (function () {
14
+ function SkipList(maxLevel, probability) {
15
+ if (maxLevel === void 0) { maxLevel = 16; }
16
+ if (probability === void 0) { probability = 0.5; }
17
+ this._head = new SkipListNode(null, null, maxLevel);
18
+ this._level = 0;
19
+ this._maxLevel = maxLevel;
20
+ this._probability = probability;
21
+ }
22
+ Object.defineProperty(SkipList.prototype, "probability", {
23
+ get: function () {
24
+ return this._probability;
25
+ },
26
+ set: function (value) {
27
+ this._probability = value;
28
+ },
29
+ enumerable: false,
30
+ configurable: true
31
+ });
32
+ Object.defineProperty(SkipList.prototype, "maxLevel", {
33
+ get: function () {
34
+ return this._maxLevel;
35
+ },
36
+ set: function (value) {
37
+ this._maxLevel = value;
38
+ },
39
+ enumerable: false,
40
+ configurable: true
41
+ });
42
+ Object.defineProperty(SkipList.prototype, "level", {
43
+ get: function () {
44
+ return this._level;
45
+ },
46
+ set: function (value) {
47
+ this._level = value;
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ Object.defineProperty(SkipList.prototype, "head", {
53
+ get: function () {
54
+ return this._head;
55
+ },
56
+ set: function (value) {
57
+ this._head = value;
58
+ },
59
+ enumerable: false,
60
+ configurable: true
61
+ });
62
+ SkipList.prototype.randomLevel = function () {
63
+ var level = 1;
64
+ while (Math.random() < this.probability && level < this.maxLevel) {
65
+ level++;
66
+ }
67
+ return level;
68
+ };
69
+ SkipList.prototype.add = function (key, value) {
70
+ var newNode = new SkipListNode(key, value, this.randomLevel());
71
+ var update = new Array(this.maxLevel).fill(this.head);
72
+ var current = this.head;
73
+ for (var i = this.level - 1; i >= 0; i--) {
74
+ while (current.forward[i] && current.forward[i].key < key) {
75
+ current = current.forward[i];
76
+ }
77
+ update[i] = current;
78
+ }
79
+ for (var i = 0; i < newNode.forward.length; i++) {
80
+ newNode.forward[i] = update[i].forward[i];
81
+ update[i].forward[i] = newNode;
82
+ }
83
+ if (newNode.forward[0] !== null) {
84
+ this.level = Math.max(this.level, newNode.forward.length);
85
+ }
86
+ };
87
+ SkipList.prototype.get = function (key) {
88
+ var current = this.head;
89
+ for (var i = this.level - 1; i >= 0; i--) {
90
+ while (current.forward[i] && current.forward[i].key < key) {
91
+ current = current.forward[i];
92
+ }
93
+ }
94
+ current = current.forward[0];
95
+ if (current && current.key === key) {
96
+ return current.value;
97
+ }
98
+ return undefined;
99
+ };
100
+ SkipList.prototype.remove = function (key) {
101
+ var update = new Array(this.maxLevel).fill(this.head);
102
+ var current = this.head;
103
+ for (var i = this.level - 1; i >= 0; i--) {
104
+ while (current.forward[i] && current.forward[i].key < key) {
105
+ current = current.forward[i];
106
+ }
107
+ update[i] = current;
108
+ }
109
+ current = current.forward[0];
110
+ if (current && current.key === key) {
111
+ for (var i = 0; i < this.level; i++) {
112
+ if (update[i].forward[i] !== current) {
113
+ break;
114
+ }
115
+ update[i].forward[i] = current.forward[i];
116
+ }
117
+ while (this.level > 0 && this.head.forward[this.level - 1] === null) {
118
+ this.level--;
119
+ }
120
+ return true;
121
+ }
122
+ return false;
123
+ };
124
+ return SkipList;
125
+ }());
126
+ exports.SkipList = SkipList;
10
127
  //# sourceMappingURL=skip-linked-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"skip-linked-list.js","sourceRoot":"","sources":["../../../src/data-structures/linked-list/skip-linked-list.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAA6B,CAAC;IAAD,qBAAC;AAAD,CAAC,AAA9B,IAA8B;AAAjB,wCAAc"}
1
+ {"version":3,"file":"skip-linked-list.js","sourceRoot":"","sources":["../../../src/data-structures/linked-list/skip-linked-list.ts"],"names":[],"mappings":";;;AAQA;IAKE,sBAAY,GAAM,EAAE,KAAQ,EAAE,KAAa;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IACH,mBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,oCAAY;AAYzB;IAyCE,kBAAY,QAAa,EAAE,WAAiB;QAAhC,yBAAA,EAAA,aAAa;QAAE,4BAAA,EAAA,iBAAiB;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAO,IAAW,EAAE,IAAW,EAAE,QAAQ,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IA7CD,sBAAI,iCAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;aAED,UAAgB,KAAa;YAC3B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC5B,CAAC;;;OAJA;IAKD,sBAAI,8BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;aAED,UAAa,KAAa;YACxB,IAAI,CAAC,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,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/types/data-structures/hash.ts"],"names":[],"mappings":""}
@@ -29,4 +29,5 @@ __exportStar(require("./heap"), exports);
29
29
  __exportStar(require("./singly-linked-list"), exports);
30
30
  __exportStar(require("./doubly-linked-list"), exports);
31
31
  __exportStar(require("./navigator"), exports);
32
+ __exportStar(require("./hash"), exports);
32
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/data-structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wCAAsB;AACtB,6CAA2B;AAC3B,iDAA+B;AAC/B,kDAAgC;AAChC,mDAAiC;AACjC,8CAA4B;AAC5B,yDAAuC;AACvC,4CAA0B;AAC1B,mDAAiC;AACjC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,uDAAqC;AACrC,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/data-structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wCAAsB;AACtB,6CAA2B;AAC3B,iDAA+B;AAC/B,kDAAgC;AAChC,mDAAiC;AACjC,8CAA4B;AAC5B,yDAAuC;AACvC,4CAA0B;AAC1B,mDAAiC;AACjC,mDAAiC;AACjC,yCAAuB;AACvB,uDAAqC;AACrC,uDAAqC;AACrC,8CAA4B;AAC5B,yCAAuB"}
package/docs/index.html CHANGED
@@ -13,7 +13,7 @@
13
13
  <div class="tsd-page-title">
14
14
  <h2>data-structure-typed</h2></div>
15
15
  <div class="tsd-panel tsd-typography"><a id="md:data-structure-typed" class="tsd-anchor"></a><h1><a href="#md:data-structure-typed">Data Structure Typed</a></h1><p>Data Structures of Javascript &amp; TypeScript.</p>
16
- <p>Do you envy languages like C++ with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">std</span>, Python with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">collections</span>, and Java with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">java.util</span>? Well, no need to envy anymore! JavaScript and TypeScript now have <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">data-structure-typed</span></p>
16
+ <p>Do you envy languages like C++ with <a href="">std</a>, Python with <a href="">collections</a>, and Java with <a href="">java.util</a> ? Well, no need to envy anymore! JavaScript and TypeScript now have <a href="">data-structure-typed</a>.</p>
17
17
  <p>Now you can use this library in Node.js and browser environments in CommonJS(require export.modules = ), ESModule(import export), Typescript(import export), UMD(var Queue = dataStructureTyped.Queue)</p>
18
18
  <p><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
19
19
  <img src="https://img.shields.io/github/languages/top/zrwusa/data-structure-typed" alt="Language">
@@ -258,24 +258,17 @@ Floyd-Warshall Algorithm, Tarjan&#39;s Algorithm.</p>
258
258
  <tr>
259
259
  <td>Set</td>
260
260
  <td>std::set&lt;T&gt;</td>
261
- <td>Set</td>
261
+ <td>Set&lt;E&gt</td>
262
262
  <td>HashSet&lt;E&gt;</td>
263
263
  <td>set</td>
264
264
  </tr>
265
265
  <tr>
266
266
  <td>Map</td>
267
267
  <td>std::map&lt;K, V&gt;</td>
268
- <td>Map</td>
268
+ <td>Map&lt;K, V&gt;</td>
269
269
  <td>HashMap&lt;K, V&gt;</td>
270
270
  <td>dict</td>
271
271
  </tr>
272
- <tr>
273
- <td>Unordered Map</td>
274
- <td>std::unordered_map&lt;K, V&gt;</td>
275
- <td>N/A</td>
276
- <td>HashMap&lt;K, V&gt;</td>
277
- <td>defaultdict</td>
278
- </tr>
279
272
  <tr>
280
273
  <td>Unordered Set</td>
281
274
  <td>std::unordered_set&lt;T&gt;</td>
@@ -283,24 +276,31 @@ Floyd-Warshall Algorithm, Tarjan&#39;s Algorithm.</p>
283
276
  <td>HashSet&lt;E&gt;</td>
284
277
  <td>N/A</td>
285
278
  </tr>
279
+ <tr>
280
+ <td>Unordered Map</td>
281
+ <td>std::unordered_map&lt;K, V&gt;</td>
282
+ <td>HashMap&lt;K, V&gt;</td>
283
+ <td>HashMap&lt;K, V&gt;</td>
284
+ <td>defaultdict</td>
285
+ </tr>
286
286
  <tr>
287
287
  <td>Queue</td>
288
288
  <td>std::queue&lt;T&gt;</td>
289
- <td>Queue</td>
289
+ <td>Queue&lt;E&gt;</td>
290
290
  <td>Queue&lt;E&gt;</td>
291
291
  <td>N/A</td>
292
292
  </tr>
293
293
  <tr>
294
294
  <td>Priority Queue</td>
295
295
  <td>std::priority_queue&lt;T&gt;</td>
296
- <td>PriorityQueue</td>
296
+ <td>PriorityQueue&lt;E&gt;</td>
297
297
  <td>PriorityQueue&lt;E&gt;</td>
298
298
  <td>N/A</td>
299
299
  </tr>
300
300
  <tr>
301
301
  <td>Stack</td>
302
302
  <td>std::stack&lt;T&gt;</td>
303
- <td>Stack</td>
303
+ <td>Stack&lt;E&gt;</td>
304
304
  <td>Stack&lt;E&gt;</td>
305
305
  <td>N/A</td>
306
306
  </tr>
@@ -314,7 +314,7 @@ Floyd-Warshall Algorithm, Tarjan&#39;s Algorithm.</p>
314
314
  <tr>
315
315
  <td>Deque</td>
316
316
  <td>std::deque&lt;T&gt;</td>
317
- <td>Deque</td>
317
+ <td>Deque&lt;E&gt;</td>
318
318
  <td>N/A</td>
319
319
  <td>N/A</td>
320
320
  </tr>
@@ -342,17 +342,10 @@ Floyd-Warshall Algorithm, Tarjan&#39;s Algorithm.</p>
342
342
  <tr>
343
343
  <td>Ordered Dictionary</td>
344
344
  <td>N/A</td>
345
- <td>Map</td>
345
+ <td>Map&lt;K, V&gt;</td>
346
346
  <td>N/A</td>
347
347
  <td>OrderedDict</td>
348
348
  </tr>
349
- <tr>
350
- <td>Double-Ended Queue (Deque)</td>
351
- <td>std::deque&lt;T&gt;</td>
352
- <td>Deque</td>
353
- <td>N/A</td>
354
- <td>N/A</td>
355
- </tr>
356
349
  <tr>
357
350
  <td>Linked Hash Set</td>
358
351
  <td>N/A</td>
@@ -370,21 +363,21 @@ Floyd-Warshall Algorithm, Tarjan&#39;s Algorithm.</p>
370
363
  <tr>
371
364
  <td>Sorted Set</td>
372
365
  <td>N/A</td>
373
- <td>AVLTree, RBTree</td>
366
+ <td>AVLTree</td>
374
367
  <td>TreeSet&lt;E&gt;</td>
375
368
  <td>N/A</td>
376
369
  </tr>
377
370
  <tr>
378
371
  <td>Sorted Map</td>
379
372
  <td>N/A</td>
380
- <td>AVLTree, RBTree</td>
373
+ <td>AVLTree</td>
381
374
  <td>TreeMap&lt;K, V&gt;</td>
382
375
  <td>N/A</td>
383
376
  </tr>
384
377
  <tr>
385
378
  <td>Tree Set</td>
386
379
  <td>std::set</td>
387
- <td>AVLTree, RBTree</td>
380
+ <td>AVLTree</td>
388
381
  <td>TreeSet&lt;E&gt;</td>
389
382
  <td>N/A</td>
390
383
  </tr>
@@ -766,8 +759,9 @@ optimal approach to data structure design.</p>
766
759
  <li><a href="classes/DirectedVertex.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Directed<wbr/>Vertex</span></a></li>
767
760
  <li><a href="classes/DoublyLinkedList.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List</span></a></li>
768
761
  <li><a href="classes/DoublyLinkedListNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
769
- <li><a href="classes/HashNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Node</span></a></li>
762
+ <li><a href="classes/HashMap.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Map</span></a></li>
770
763
  <li><a href="classes/HashTable.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Table</span></a></li>
764
+ <li><a href="classes/HashTableNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Hash<wbr/>Table<wbr/>Node</span></a></li>
771
765
  <li><a href="classes/Heap.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap</span></a></li>
772
766
  <li><a href="classes/HeapItem.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Heap<wbr/>Item</span></a></li>
773
767
  <li><a href="classes/LinkedListQueue.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Linked<wbr/>List<wbr/>Queue</span></a></li>
@@ -791,7 +785,8 @@ optimal approach to data structure design.</p>
791
785
  <li><a href="classes/SegmentTreeNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Segment<wbr/>Tree<wbr/>Node</span></a></li>
792
786
  <li><a href="classes/SinglyLinkedList.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Singly<wbr/>Linked<wbr/>List</span></a></li>
793
787
  <li><a href="classes/SinglyLinkedListNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Singly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
794
- <li><a href="classes/SkipLinkedList.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Skip<wbr/>Linked<wbr/>List</span></a></li>
788
+ <li><a href="classes/SkipList.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Skip<wbr/>List</span></a></li>
789
+ <li><a href="classes/SkipListNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Skip<wbr/>List<wbr/>Node</span></a></li>
795
790
  <li><a href="classes/SplayTree.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Splay<wbr/>Tree</span></a></li>
796
791
  <li><a href="classes/Stack.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Stack</span></a></li>
797
792
  <li><a href="classes/TreeMap.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Tree<wbr/>Map</span></a></li>
@@ -833,6 +828,7 @@ optimal approach to data structure design.</p>
833
828
  <li><a href="types/Direction.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Direction</span></a></li>
834
829
  <li><a href="types/DummyAny.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Dummy<wbr/>Any</span></a></li>
835
830
  <li><a href="types/EdgeId.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Edge<wbr/>Id</span></a></li>
831
+ <li><a href="types/HashFunction.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Hash<wbr/>Function</span></a></li>
836
832
  <li><a href="types/HeapOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Heap<wbr/>Options</span></a></li>
837
833
  <li><a href="types/IAVLTreeNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>IAVLTree<wbr/>Node</span></a></li>
838
834
  <li><a href="types/IBSTNode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>IBSTNode</span></a></li>