data-structure-typed 1.46.2 → 1.46.3

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.
@@ -5,48 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { HashMapLinkedNode, IterableWithSizeOrLength, IterateDirection } from '../../types';
9
- /**
10
- * Because the implementation of HashMap relies on JavaScript's built-in objects and arrays,
11
- * these underlying structures have already dealt with dynamic expansion and hash collisions.
12
- * Therefore, there is no need for additional logic to handle these issues.
13
- */
14
- export declare class HashMapIterator<K, V> {
15
- readonly hashMap: HashMap<K, V>;
16
- readonly iterateDirection: IterateDirection;
17
- protected _node: HashMapLinkedNode<K, V>;
18
- protected readonly _sentinel: HashMapLinkedNode<K, V>;
19
- /**
20
- * This is a constructor function for a linked list iterator in a HashMap data structure.
21
- * @param node - The `node` parameter is a reference to a `HashMapLinkedNode` object. This object
22
- * represents a node in a linked list used in a hash map data structure. It contains a key-value pair
23
- * and references to the previous and next nodes in the linked list.
24
- * @param sentinel - The `sentinel` parameter is a reference to a special node in a linked list. It
25
- * is used to mark the beginning or end of the list and is typically used in data structures like
26
- * hash maps or linked lists to simplify operations and boundary checks.
27
- * @param hashMap - A HashMap object that stores key-value pairs.
28
- * @param {IterateDirection} iterateDirection - The `iterateDirection` parameter is an optional
29
- * parameter that specifies the direction in which the iterator should iterate over the elements of
30
- * the HashMap. It can take one of the following values:
31
- * @returns The constructor does not return anything. It is used to initialize the properties and
32
- * methods of the object being created.
33
- */
34
- constructor(node: HashMapLinkedNode<K, V>, sentinel: HashMapLinkedNode<K, V>, hashMap: HashMap<K, V>, iterateDirection?: IterateDirection);
35
- /**
36
- * The above function returns a Proxy object that allows access to the key and value of a node in a
37
- * data structure.
38
- * @returns The code is returning a Proxy object.
39
- */
40
- get current(): [K, V];
41
- /**
42
- * The function checks if a node is accessible.
43
- * @returns a boolean value indicating whether the `_node` is not equal to the `_sentinel`.
44
- */
45
- isAccessible(): boolean;
46
- prev(): this;
47
- next(): this;
48
- clone(): HashMapIterator<K, V>;
49
- }
8
+ import { HashMapLinkedNode, IterableWithSizeOrLength } from '../../types';
50
9
  export declare class HashMap<K = any, V = any> {
51
10
  readonly OBJ_KEY_INDEX: symbol;
52
11
  protected _nodes: HashMapLinkedNode<K, V>[];
@@ -63,41 +22,6 @@ export declare class HashMap<K = any, V = any> {
63
22
  constructor(elements?: IterableWithSizeOrLength<[K, V]>);
64
23
  protected _size: number;
65
24
  get size(): number;
66
- /**
67
- * Time Complexity: O(1)
68
- * Space Complexity: O(1)
69
- *
70
- * The function returns a new iterator object for a HashMap.
71
- * @returns A new instance of the HashMapIterator class is being returned.
72
- */
73
- get begin(): HashMapIterator<K, V>;
74
- /**
75
- * Time Complexity: O(1)
76
- * Space Complexity: O(1)
77
- *
78
- * The function returns a new HashMapIterator object with the _sentinel value as both the start and
79
- * end values.
80
- * @returns A new instance of the HashMapIterator class is being returned.
81
- */
82
- get end(): HashMapIterator<K, V>;
83
- /**
84
- * Time Complexity: O(1)
85
- * Space Complexity: O(1)
86
- *
87
- * The reverseBegin function returns a new HashMapIterator object that iterates over the elements of
88
- * a HashMap in reverse order.
89
- * @returns A new instance of the HashMapIterator class is being returned.
90
- */
91
- get reverseBegin(): HashMapIterator<K, V>;
92
- /**
93
- * Time Complexity: O(1)
94
- * Space Complexity: O(1)
95
- *
96
- * The reverseEnd function returns a new HashMapIterator object that iterates over the elements of a
97
- * HashMap in reverse order.
98
- * @returns A new instance of the HashMapIterator class is being returned.
99
- */
100
- get reverseEnd(): HashMapIterator<K, V>;
101
25
  /**
102
26
  * Time Complexity: O(1)
103
27
  * Space Complexity: O(1)
@@ -116,6 +40,15 @@ export declare class HashMap<K = any, V = any> {
116
40
  * data structure.
117
41
  */
118
42
  get last(): [K, V] | undefined;
43
+ /**
44
+ * The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
45
+ */
46
+ begin(): Generator<(K | V)[], void, unknown>;
47
+ /**
48
+ * The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
49
+ * key and value.
50
+ */
51
+ reverseBegin(): Generator<(K | V)[], void, unknown>;
119
52
  /**
120
53
  * Time Complexity: O(1)
121
54
  * Space Complexity: O(1)
@@ -159,20 +92,6 @@ export declare class HashMap<K = any, V = any> {
159
92
  * where `K` is the key and `V` is the value.
160
93
  */
161
94
  getAt(index: number): [K, V];
162
- /**
163
- * Time Complexity: O(1)
164
- * Space Complexity: O(1)
165
- *
166
- * The function `getIterator` returns a new instance of `HashMapIterator` based on the provided key
167
- * and whether it is an object key or not.
168
- * @param {K} key - The `key` parameter is the key used to retrieve the iterator from the HashMap. It
169
- * can be of any type, depending on how the HashMap is implemented.
170
- * @param {boolean} [isObjectKey] - The `isObjectKey` parameter is an optional boolean parameter that
171
- * indicates whether the `key` parameter is an object key. If `isObjectKey` is `true`, it means that
172
- * the `key` parameter is an object and needs to be handled differently. If `isObjectKey` is `false`
173
- * @returns a new instance of the `HashMapIterator` class.
174
- */
175
- getIterator(key: K, isObjectKey?: boolean): HashMapIterator<K, V>;
176
95
  /**
177
96
  * Time Complexity: O(1)
178
97
  * Space Complexity: O(1)
@@ -7,113 +7,8 @@
7
7
  * @license MIT License
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.HashMap = exports.HashMapIterator = void 0;
10
+ exports.HashMap = void 0;
11
11
  const utils_1 = require("../../utils");
12
- /**
13
- * Because the implementation of HashMap relies on JavaScript's built-in objects and arrays,
14
- * these underlying structures have already dealt with dynamic expansion and hash collisions.
15
- * Therefore, there is no need for additional logic to handle these issues.
16
- */
17
- class HashMapIterator {
18
- /**
19
- * This is a constructor function for a linked list iterator in a HashMap data structure.
20
- * @param node - The `node` parameter is a reference to a `HashMapLinkedNode` object. This object
21
- * represents a node in a linked list used in a hash map data structure. It contains a key-value pair
22
- * and references to the previous and next nodes in the linked list.
23
- * @param sentinel - The `sentinel` parameter is a reference to a special node in a linked list. It
24
- * is used to mark the beginning or end of the list and is typically used in data structures like
25
- * hash maps or linked lists to simplify operations and boundary checks.
26
- * @param hashMap - A HashMap object that stores key-value pairs.
27
- * @param {IterateDirection} iterateDirection - The `iterateDirection` parameter is an optional
28
- * parameter that specifies the direction in which the iterator should iterate over the elements of
29
- * the HashMap. It can take one of the following values:
30
- * @returns The constructor does not return anything. It is used to initialize the properties and
31
- * methods of the object being created.
32
- */
33
- constructor(node, sentinel, hashMap, iterateDirection = 0 /* IterateDirection.DEFAULT */) {
34
- this._node = node;
35
- this._sentinel = sentinel;
36
- this.iterateDirection = iterateDirection;
37
- if (this.iterateDirection === 0 /* IterateDirection.DEFAULT */) {
38
- this.prev = function () {
39
- if (this._node.prev === this._sentinel) {
40
- (0, utils_1.throwRangeError)();
41
- }
42
- this._node = this._node.prev;
43
- return this;
44
- };
45
- this.next = function () {
46
- if (this._node === this._sentinel) {
47
- (0, utils_1.throwRangeError)();
48
- }
49
- this._node = this._node.next;
50
- return this;
51
- };
52
- }
53
- else {
54
- this.prev = function () {
55
- if (this._node.next === this._sentinel) {
56
- (0, utils_1.throwRangeError)();
57
- }
58
- this._node = this._node.next;
59
- return this;
60
- };
61
- this.next = function () {
62
- if (this._node === this._sentinel) {
63
- (0, utils_1.throwRangeError)();
64
- }
65
- this._node = this._node.prev;
66
- return this;
67
- };
68
- }
69
- this.hashMap = hashMap;
70
- }
71
- /**
72
- * The above function returns a Proxy object that allows access to the key and value of a node in a
73
- * data structure.
74
- * @returns The code is returning a Proxy object.
75
- */
76
- get current() {
77
- if (this._node === this._sentinel) {
78
- (0, utils_1.throwRangeError)();
79
- }
80
- return new Proxy([], {
81
- get: (target, prop) => {
82
- if (prop === '0')
83
- return this._node.key;
84
- else if (prop === '1')
85
- return this._node.value;
86
- target[0] = this._node.key;
87
- target[1] = this._node.value;
88
- return target[prop];
89
- },
90
- set: (_, prop, newValue) => {
91
- if (prop !== '1') {
92
- throw new TypeError(`prop should be string '1'`);
93
- }
94
- this._node.value = newValue;
95
- return true;
96
- }
97
- });
98
- }
99
- /**
100
- * The function checks if a node is accessible.
101
- * @returns a boolean value indicating whether the `_node` is not equal to the `_sentinel`.
102
- */
103
- isAccessible() {
104
- return this._node !== this._sentinel;
105
- }
106
- prev() {
107
- return this;
108
- }
109
- next() {
110
- return this;
111
- }
112
- clone() {
113
- return new HashMapIterator(this._node, this._sentinel, this.hashMap, this.iterateDirection);
114
- }
115
- }
116
- exports.HashMapIterator = HashMapIterator;
117
12
  class HashMap {
118
13
  /**
119
14
  * The constructor initializes a HashMap object with an optional initial set of key-value pairs.
@@ -136,49 +31,6 @@ class HashMap {
136
31
  get size() {
137
32
  return this._size;
138
33
  }
139
- /**
140
- * Time Complexity: O(1)
141
- * Space Complexity: O(1)
142
- *
143
- * The function returns a new iterator object for a HashMap.
144
- * @returns A new instance of the HashMapIterator class is being returned.
145
- */
146
- get begin() {
147
- return new HashMapIterator(this._head, this._sentinel, this);
148
- }
149
- /**
150
- * Time Complexity: O(1)
151
- * Space Complexity: O(1)
152
- *
153
- * The function returns a new HashMapIterator object with the _sentinel value as both the start and
154
- * end values.
155
- * @returns A new instance of the HashMapIterator class is being returned.
156
- */
157
- get end() {
158
- return new HashMapIterator(this._sentinel, this._sentinel, this);
159
- }
160
- /**
161
- * Time Complexity: O(1)
162
- * Space Complexity: O(1)
163
- *
164
- * The reverseBegin function returns a new HashMapIterator object that iterates over the elements of
165
- * a HashMap in reverse order.
166
- * @returns A new instance of the HashMapIterator class is being returned.
167
- */
168
- get reverseBegin() {
169
- return new HashMapIterator(this._tail, this._sentinel, this, 1 /* IterateDirection.REVERSE */);
170
- }
171
- /**
172
- * Time Complexity: O(1)
173
- * Space Complexity: O(1)
174
- *
175
- * The reverseEnd function returns a new HashMapIterator object that iterates over the elements of a
176
- * HashMap in reverse order.
177
- * @returns A new instance of the HashMapIterator class is being returned.
178
- */
179
- get reverseEnd() {
180
- return new HashMapIterator(this._sentinel, this._sentinel, this, 1 /* IterateDirection.REVERSE */);
181
- }
182
34
  /**
183
35
  * Time Complexity: O(1)
184
36
  * Space Complexity: O(1)
@@ -205,6 +57,27 @@ class HashMap {
205
57
  return;
206
58
  return [this._tail.key, this._tail.value];
207
59
  }
60
+ /**
61
+ * The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
62
+ */
63
+ *begin() {
64
+ let node = this._head;
65
+ while (node !== this._sentinel) {
66
+ yield [node.key, node.value];
67
+ node = node.next;
68
+ }
69
+ }
70
+ /**
71
+ * The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
72
+ * key and value.
73
+ */
74
+ *reverseBegin() {
75
+ let node = this._tail;
76
+ while (node !== this._sentinel) {
77
+ yield [node.key, node.value];
78
+ node = node.prev;
79
+ }
80
+ }
208
81
  /**
209
82
  * Time Complexity: O(1)
210
83
  * Space Complexity: O(1)
@@ -305,35 +178,6 @@ class HashMap {
305
178
  }
306
179
  return [node.key, node.value];
307
180
  }
308
- /**
309
- * Time Complexity: O(1)
310
- * Space Complexity: O(1)
311
- *
312
- * The function `getIterator` returns a new instance of `HashMapIterator` based on the provided key
313
- * and whether it is an object key or not.
314
- * @param {K} key - The `key` parameter is the key used to retrieve the iterator from the HashMap. It
315
- * can be of any type, depending on how the HashMap is implemented.
316
- * @param {boolean} [isObjectKey] - The `isObjectKey` parameter is an optional boolean parameter that
317
- * indicates whether the `key` parameter is an object key. If `isObjectKey` is `true`, it means that
318
- * the `key` parameter is an object and needs to be handled differently. If `isObjectKey` is `false`
319
- * @returns a new instance of the `HashMapIterator` class.
320
- */
321
- getIterator(key, isObjectKey) {
322
- let node;
323
- if (isObjectKey) {
324
- const index = key[this.OBJ_KEY_INDEX];
325
- if (index === undefined) {
326
- node = this._sentinel;
327
- }
328
- else {
329
- node = this._nodes[index];
330
- }
331
- }
332
- else {
333
- node = this._orgMap[key] || this._sentinel;
334
- }
335
- return new HashMapIterator(node, this._sentinel, this);
336
- }
337
181
  /**
338
182
  * Time Complexity: O(1)
339
183
  * Space Complexity: O(1)
@@ -1 +1 @@
1
- {"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAuE;AAGvE;;;;GAIG;AACH,MAAa,eAAe;IAM1B;;;;;;;;;;;;;;OAcG;IACH,YACE,IAA6B,EAC7B,QAAiC,EACjC,OAAsB,EACtB,mDAA6D;QAE7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,IAAI,IAAI,CAAC,gBAAgB,qCAA6B,EAAE;YACtD,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;oBACtC,IAAA,uBAAe,GAAE,CAAC;iBACnB;gBACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACF,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE;oBACjC,IAAA,uBAAe,GAAE,CAAC;iBACnB;gBACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;SACH;aAAM;YACL,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;oBACtC,IAAA,uBAAe,GAAE,CAAC;iBACnB;gBACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACF,IAAI,CAAC,IAAI,G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IAAI,CAAC,KAAK,CAAC;QACtB,OAAO,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;YAC9B,MAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SAClB;IACH,CAAC;IAED;;;;;;;;;OASG;IACO,WAAW,CAAC,IAA6B;QACjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QACD,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QACD,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AAzTD,0BAyTC"}
@@ -5,39 +5,13 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { IterableWithSizeOrLength, IterateDirection } from "../../types";
8
+ import { IterableWithSizeOrLength } from "../../types";
9
9
  /**
10
10
  * Deque can provide random access with O(1) time complexity
11
11
  * Deque is usually more compact and efficient in memory usage because it does not require additional space to store pointers.
12
12
  * Deque may experience performance jitter, but DoublyLinkedList will not
13
13
  * Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
14
14
  */
15
- export declare class DequeIterator<E> {
16
- iterateDirection: IterateDirection;
17
- index: number;
18
- readonly deque: Deque<E>;
19
- /**
20
- * The constructor initializes the index, iterate direction, and prev/next functions for a
21
- * DequeIterator object.
22
- * @param {number} index - The index parameter represents the current index position of the iterator
23
- * within the deque. It is a number that indicates the position of the element that the iterator is
24
- * currently pointing to.
25
- * @param deque - The `deque` parameter is an instance of the `Deque` class. It represents a
26
- * double-ended queue data structure, which allows elements to be added or removed from both ends.
27
- * @param iterateDirection - The `iterateDirection` parameter is an optional parameter that specifies
28
- * the direction in which the iterator should iterate over the elements of the `deque`. It has a
29
- * default value of `IterateDirection.DEFAULT`.
30
- * @returns The constructor is not returning anything. It is used to initialize the properties of the
31
- * object being created.
32
- */
33
- constructor(index: number, deque: Deque<E>, iterateDirection?: IterateDirection);
34
- get current(): E;
35
- set current(newElement: E);
36
- isAccessible(): boolean;
37
- prev(): DequeIterator<E>;
38
- next(): DequeIterator<E>;
39
- clone(): DequeIterator<E>;
40
- }
41
15
  export declare class Deque<E> {
42
16
  protected _bucketFirst: number;
43
17
  protected _firstInBucket: number;
@@ -120,28 +94,14 @@ export declare class Deque<E> {
120
94
  */
121
95
  clear(): void;
122
96
  /**
123
- * The `begin()` function returns a new iterator for a deque starting from the first element.
124
- * @returns A new instance of the DequeIterator class is being returned.
125
- */
126
- begin(): DequeIterator<E>;
127
- /**
128
- * The `end()` function returns a new `DequeIterator` object with the size and reference to the
129
- * current deque.
130
- * @returns A new instance of the DequeIterator class is being returned.
97
+ * The below function is a generator that yields elements from a collection one by one.
131
98
  */
132
- end(): DequeIterator<E>;
99
+ begin(): Generator<E>;
133
100
  /**
134
- * The reverseBegin function returns a new DequeIterator object that starts at the last element of
135
- * the deque and iterates in reverse direction.
136
- * @returns A new instance of the DequeIterator class is being returned.
101
+ * The function `reverseBegin()` is a generator that yields elements in reverse order starting from
102
+ * the last element.
137
103
  */
138
- reverseBegin(): DequeIterator<E>;
139
- /**
140
- * The reverseEnd() function returns a new DequeIterator object that iterates over the elements of a
141
- * Deque in reverse order.
142
- * @returns A new instance of the DequeIterator class is being returned.
143
- */
144
- reverseEnd(): DequeIterator<E>;
104
+ reverseBegin(): Generator<E>;
145
105
  /**
146
106
  * Time Complexity - Amortized O(1) (possible reallocation)
147
107
  * Space Complexity - O(n) (due to potential resizing).
@@ -294,34 +254,6 @@ export declare class Deque<E> {
294
254
  * @returns The size of the data structure after the element has been deleted.
295
255
  */
296
256
  delete(element: E): number;
297
- /**
298
- * Time Complexity: O(n)
299
- * Space Complexity: O(1)
300
- */
301
- /**
302
- * Time Complexity: O(n)
303
- * Space Complexity: O(1)
304
- *
305
- * The function deletes an element from a deque using an iterator and returns the next iterator.
306
- * @param iter - The parameter `iter` is of type `DequeIterator<E>`. It represents an iterator object
307
- * that is used to iterate over elements in a deque (double-ended queue).
308
- * @returns the updated iterator after deleting an element from the deque.
309
- */
310
- deleteByIterator(iter: DequeIterator<E>): DequeIterator<E>;
311
- /**
312
- * Time Complexity: O(n)
313
- * Space Complexity: O(1)
314
- */
315
- /**
316
- * Time Complexity: O(n)
317
- * Space Complexity: O(1)
318
- *
319
- * The function `findIterator` searches for an element in a deque and returns an iterator pointing to
320
- * the element if found, otherwise it returns an iterator pointing to the end of the deque.
321
- * @param {E} element - The `element` parameter is the element that you want to find in the deque.
322
- * @returns The method `findIterator(element: E)` returns a `DequeIterator<E>` object.
323
- */
324
- findIterator(element: E): DequeIterator<E>;
325
257
  /**
326
258
  * Time Complexity: O(n)
327
259
  * Space Complexity: O(1)