data-structure-typed 1.49.1 → 1.49.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +16 -16
  3. package/README_zh-CN.md +2 -2
  4. package/benchmark/report.html +46 -1
  5. package/benchmark/report.json +457 -22
  6. package/dist/cjs/data-structures/base/iterable-base.d.ts +11 -0
  7. package/dist/cjs/data-structures/base/iterable-base.js +21 -0
  8. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  9. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +7 -7
  10. package/dist/cjs/data-structures/graph/abstract-graph.js +43 -12
  11. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  12. package/dist/cjs/data-structures/graph/directed-graph.d.ts +2 -2
  13. package/dist/cjs/data-structures/graph/directed-graph.js +2 -2
  14. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  15. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +1 -1
  16. package/dist/cjs/data-structures/graph/undirected-graph.js +1 -1
  17. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  18. package/dist/cjs/data-structures/hash/hash-map.d.ts +9 -9
  19. package/dist/cjs/data-structures/hash/hash-map.js +16 -15
  20. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  21. package/dist/cjs/data-structures/heap/heap.d.ts +6 -35
  22. package/dist/cjs/data-structures/heap/heap.js +10 -42
  23. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  24. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +99 -105
  25. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +143 -146
  26. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  27. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  28. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +42 -42
  29. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  30. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +25 -25
  31. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +36 -36
  32. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  33. package/dist/cjs/data-structures/queue/deque.d.ts +70 -75
  34. package/dist/cjs/data-structures/queue/deque.js +100 -110
  35. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  36. package/dist/cjs/data-structures/queue/queue.d.ts +37 -38
  37. package/dist/cjs/data-structures/queue/queue.js +46 -49
  38. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  39. package/dist/cjs/data-structures/stack/stack.d.ts +2 -3
  40. package/dist/cjs/data-structures/stack/stack.js +2 -5
  41. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  42. package/dist/cjs/data-structures/trie/trie.d.ts +1 -2
  43. package/dist/cjs/data-structures/trie/trie.js +2 -5
  44. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  45. package/dist/mjs/data-structures/base/iterable-base.d.ts +11 -0
  46. package/dist/mjs/data-structures/base/iterable-base.js +21 -0
  47. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +7 -7
  48. package/dist/mjs/data-structures/graph/abstract-graph.js +43 -12
  49. package/dist/mjs/data-structures/graph/directed-graph.d.ts +2 -2
  50. package/dist/mjs/data-structures/graph/directed-graph.js +2 -2
  51. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +1 -1
  52. package/dist/mjs/data-structures/graph/undirected-graph.js +1 -1
  53. package/dist/mjs/data-structures/hash/hash-map.d.ts +9 -9
  54. package/dist/mjs/data-structures/hash/hash-map.js +16 -15
  55. package/dist/mjs/data-structures/heap/heap.d.ts +6 -35
  56. package/dist/mjs/data-structures/heap/heap.js +10 -42
  57. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +99 -105
  58. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +142 -145
  59. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  60. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +43 -43
  61. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +25 -25
  62. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +36 -36
  63. package/dist/mjs/data-structures/queue/deque.d.ts +70 -75
  64. package/dist/mjs/data-structures/queue/deque.js +100 -110
  65. package/dist/mjs/data-structures/queue/queue.d.ts +37 -38
  66. package/dist/mjs/data-structures/queue/queue.js +45 -48
  67. package/dist/mjs/data-structures/stack/stack.d.ts +2 -3
  68. package/dist/mjs/data-structures/stack/stack.js +2 -5
  69. package/dist/mjs/data-structures/trie/trie.d.ts +1 -2
  70. package/dist/mjs/data-structures/trie/trie.js +2 -5
  71. package/dist/umd/data-structure-typed.js +531 -532
  72. package/dist/umd/data-structure-typed.min.js +2 -2
  73. package/dist/umd/data-structure-typed.min.js.map +1 -1
  74. package/package.json +1 -1
  75. package/src/data-structures/base/iterable-base.ts +24 -0
  76. package/src/data-structures/graph/abstract-graph.ts +55 -14
  77. package/src/data-structures/graph/directed-graph.ts +3 -2
  78. package/src/data-structures/graph/undirected-graph.ts +1 -1
  79. package/src/data-structures/hash/hash-map.ts +27 -28
  80. package/src/data-structures/heap/heap.ts +19 -57
  81. package/src/data-structures/linked-list/doubly-linked-list.ts +157 -161
  82. package/src/data-structures/linked-list/singly-linked-list.ts +49 -49
  83. package/src/data-structures/linked-list/skip-linked-list.ts +40 -40
  84. package/src/data-structures/queue/deque.ts +122 -135
  85. package/src/data-structures/queue/queue.ts +54 -58
  86. package/src/data-structures/stack/stack.ts +4 -8
  87. package/src/data-structures/trie/trie.ts +5 -9
  88. package/test/performance/data-structures/comparison/comparison.test.ts +6 -6
  89. package/test/performance/data-structures/heap/heap.test.ts +2 -2
  90. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +2 -2
  91. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +2 -2
  92. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +2 -2
  93. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +2 -2
  94. package/test/unit/data-structures/graph/abstract-graph.test.ts +1 -1
  95. package/test/unit/data-structures/graph/directed-graph.test.ts +48 -3
  96. package/test/unit/data-structures/graph/undirected-graph.test.ts +48 -4
  97. package/test/unit/data-structures/hash/hash-map.test.ts +2 -2
  98. package/test/unit/data-structures/heap/heap.test.ts +6 -1
  99. package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
  100. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +30 -30
  101. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
  102. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +21 -21
  103. package/test/unit/data-structures/linked-list/skip-list.test.ts +2 -2
  104. package/test/unit/data-structures/queue/deque.test.ts +5 -5
  105. package/test/unit/data-structures/queue/queue.test.ts +4 -4
  106. package/test/unit/data-structures/trie/trie.test.ts +1 -1
@@ -32,6 +32,32 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
32
32
  * @returns {number} The size of the array, which is the difference between the length of the array and the offset.
33
33
  */
34
34
  get size(): number;
35
+ /**
36
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
37
+ * Space Complexity: O(1) - no additional space is used.
38
+ *
39
+ * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
40
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
41
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
42
+ */
43
+ get first(): E | undefined;
44
+ /**
45
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
46
+ * Space Complexity: O(1) - no additional space is used.
47
+ */
48
+ /**
49
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
50
+ * Space Complexity: O(1) - no additional space is used.
51
+ *
52
+ * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
53
+ * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
54
+ * array is empty, it returns `undefined`.
55
+ */
56
+ get last(): E | undefined;
57
+ /**
58
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
59
+ * Space Complexity: O(1) - no additional space is used.
60
+ */
35
61
  /**
36
62
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
37
63
  * @public
@@ -42,7 +68,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
42
68
  */
43
69
  static fromArray<E>(elements: E[]): Queue<E>;
44
70
  /**
45
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
71
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
46
72
  * Space Complexity: O(1) - no additional space is used.
47
73
  */
48
74
  /**
@@ -53,9 +79,9 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
53
79
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
54
80
  * @returns The `add` method is returning a `Queue<E>` object.
55
81
  */
56
- push(element: E): Queue<E>;
82
+ push(element: E): boolean;
57
83
  /**
58
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
84
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
59
85
  * Space Complexity: O(1) - no additional space is used.
60
86
  */
61
87
  /**
@@ -67,19 +93,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
67
93
  * @returns The function `shift()` returns either the first element in the queue or `undefined` if the queue is empty.
68
94
  */
69
95
  shift(): E | undefined;
70
- /**
71
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
72
- * Space Complexity: O(1) - no additional space is used.
73
- */
74
- /**
75
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
76
- * Space Complexity: O(1) - no additional space is used.
77
- *
78
- * The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
79
- * @returns The `getFirst()` method returns the first element of the data structure, represented by the `_nodes` array at
80
- * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
81
- */
82
- getFirst(): E | undefined;
83
96
  /**
84
97
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
85
98
  * Space Complexity: O(1) - no additional space is used.
@@ -93,19 +106,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
93
106
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
94
107
  */
95
108
  peek(): E | undefined;
96
- /**
97
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
98
- * Space Complexity: O(1) - no additional space is used.
99
- */
100
- /**
101
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
102
- * Space Complexity: O(1) - no additional space is used.
103
- *
104
- * The `getLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
105
- * @returns The method `getLast()` returns the last element of the `_nodes` array if the array is not empty. If the
106
- * array is empty, it returns `undefined`.
107
- */
108
- getLast(): E | undefined;
109
109
  /**
110
110
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
111
111
  * Space Complexity: O(1) - no additional space is used.
@@ -130,7 +130,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
130
130
  * The enqueue function adds a value to the end of a queue.
131
131
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
132
132
  */
133
- enqueue(value: E): Queue<E>;
133
+ enqueue(value: E): boolean;
134
134
  /**
135
135
  * Time Complexity: O(n) - same as shift().
136
136
  * Space Complexity: O(1) - same as shift().
@@ -194,7 +194,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
194
194
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
195
195
  */
196
196
  clone(): Queue<E>;
197
- print(): void;
198
197
  /**
199
198
  * Time Complexity: O(n)
200
199
  * Space Complexity: O(n)
@@ -239,7 +238,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
239
238
  * Time Complexity: O(n)
240
239
  * Space Complexity: O(n)
241
240
  */
242
- protected _getIterator(): Generator<E, void, unknown>;
241
+ protected _getIterator(): IterableIterator<E>;
243
242
  }
244
243
  /**
245
244
  * 1. First In, First Out (FIFO) Strategy: Like other queue implementations, LinkedListQueue follows the first in, first out principle, meaning the element that is added to the queue first will be the first to be removed.
@@ -248,21 +247,21 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
248
247
  * 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
249
248
  */
250
249
  export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
250
+ /**
251
+ * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
252
+ * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
253
+ */
254
+ get first(): E | undefined;
251
255
  /**
252
256
  * The enqueue function adds a value to the end of an array.
253
257
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
254
258
  */
255
- enqueue(value: E): void;
259
+ enqueue(value: E): boolean;
256
260
  /**
257
261
  * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
258
262
  * @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
259
263
  */
260
264
  dequeue(): E | undefined;
261
- /**
262
- * The `getFirst` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
263
- * @returns The `getFirst()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
264
- */
265
- getFirst(): E | undefined;
266
265
  /**
267
266
  * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
268
267
  * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
@@ -37,6 +37,36 @@ class Queue extends base_1.IterableElementBase {
37
37
  get size() {
38
38
  return this.nodes.length - this.offset;
39
39
  }
40
+ /**
41
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
42
+ * Space Complexity: O(1) - no additional space is used.
43
+ *
44
+ * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
45
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
46
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
47
+ */
48
+ get first() {
49
+ return this.size > 0 ? this.nodes[this.offset] : undefined;
50
+ }
51
+ /**
52
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
53
+ * Space Complexity: O(1) - no additional space is used.
54
+ */
55
+ /**
56
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
57
+ * Space Complexity: O(1) - no additional space is used.
58
+ *
59
+ * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
60
+ * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
61
+ * array is empty, it returns `undefined`.
62
+ */
63
+ get last() {
64
+ return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
65
+ }
66
+ /**
67
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
68
+ * Space Complexity: O(1) - no additional space is used.
69
+ */
40
70
  /**
41
71
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
42
72
  * @public
@@ -49,7 +79,7 @@ class Queue extends base_1.IterableElementBase {
49
79
  return new Queue(elements);
50
80
  }
51
81
  /**
52
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
82
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
53
83
  * Space Complexity: O(1) - no additional space is used.
54
84
  */
55
85
  /**
@@ -62,10 +92,10 @@ class Queue extends base_1.IterableElementBase {
62
92
  */
63
93
  push(element) {
64
94
  this.nodes.push(element);
65
- return this;
95
+ return true;
66
96
  }
67
97
  /**
68
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
98
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
69
99
  * Space Complexity: O(1) - no additional space is used.
70
100
  */
71
101
  /**
@@ -79,7 +109,7 @@ class Queue extends base_1.IterableElementBase {
79
109
  shift() {
80
110
  if (this.size === 0)
81
111
  return undefined;
82
- const first = this.getFirst();
112
+ const first = this.first;
83
113
  this._offset += 1;
84
114
  if (this.offset * 2 < this.nodes.length)
85
115
  return first;
@@ -89,21 +119,6 @@ class Queue extends base_1.IterableElementBase {
89
119
  this._offset = 0;
90
120
  return first;
91
121
  }
92
- /**
93
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
94
- * Space Complexity: O(1) - no additional space is used.
95
- */
96
- /**
97
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
98
- * Space Complexity: O(1) - no additional space is used.
99
- *
100
- * The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
101
- * @returns The `getFirst()` method returns the first element of the data structure, represented by the `_nodes` array at
102
- * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
103
- */
104
- getFirst() {
105
- return this.size > 0 ? this.nodes[this.offset] : undefined;
106
- }
107
122
  /**
108
123
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
109
124
  * Space Complexity: O(1) - no additional space is used.
@@ -117,22 +132,7 @@ class Queue extends base_1.IterableElementBase {
117
132
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
118
133
  */
119
134
  peek() {
120
- return this.getFirst();
121
- }
122
- /**
123
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
124
- * Space Complexity: O(1) - no additional space is used.
125
- */
126
- /**
127
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
128
- * Space Complexity: O(1) - no additional space is used.
129
- *
130
- * The `getLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
131
- * @returns The method `getLast()` returns the last element of the `_nodes` array if the array is not empty. If the
132
- * array is empty, it returns `undefined`.
133
- */
134
- getLast() {
135
- return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
135
+ return this.first;
136
136
  }
137
137
  /**
138
138
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
@@ -147,7 +147,7 @@ class Queue extends base_1.IterableElementBase {
147
147
  * array is empty, it returns `undefined`.
148
148
  */
149
149
  peekLast() {
150
- return this.getLast();
150
+ return this.last;
151
151
  }
152
152
  /**
153
153
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
@@ -239,9 +239,6 @@ class Queue extends base_1.IterableElementBase {
239
239
  clone() {
240
240
  return new Queue(this.nodes.slice(this.offset));
241
241
  }
242
- print() {
243
- console.log([...this]);
244
- }
245
242
  /**
246
243
  * Time Complexity: O(n)
247
244
  * Space Complexity: O(n)
@@ -318,12 +315,20 @@ exports.Queue = Queue;
318
315
  * 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
319
316
  */
320
317
  class LinkedListQueue extends linked_list_1.SinglyLinkedList {
318
+ /**
319
+ * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
320
+ * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
321
+ */
322
+ get first() {
323
+ var _a;
324
+ return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
325
+ }
321
326
  /**
322
327
  * The enqueue function adds a value to the end of an array.
323
328
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
324
329
  */
325
330
  enqueue(value) {
326
- this.push(value);
331
+ return this.push(value);
327
332
  }
328
333
  /**
329
334
  * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
@@ -332,20 +337,12 @@ class LinkedListQueue extends linked_list_1.SinglyLinkedList {
332
337
  dequeue() {
333
338
  return this.shift();
334
339
  }
335
- /**
336
- * The `getFirst` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
337
- * @returns The `getFirst()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
338
- */
339
- getFirst() {
340
- var _a;
341
- return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
342
- }
343
340
  /**
344
341
  * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
345
342
  * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
346
343
  */
347
344
  peek() {
348
- return this.getFirst();
345
+ return this.first;
349
346
  }
350
347
  }
351
348
  exports.LinkedListQueue = LinkedListQueue;
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../src/data-structures/queue/queue.ts"],"names":[],"mappings":";;;AAMA,kCAA8C;AAC9C,gDAAkD;AAElD;;;;;;;;GAQG;AACH,MAAa,KAAe,SAAQ,0BAAsB;IACxD;;;;;OAKG;IACH,YAAY,QAAc;QACxB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,QAAQ,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAID,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,CAAI,QAAa;QAC/B,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IAEH;;;;;;;OAOG;IACH,IAAI,CAAC,OAAU;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IAEH;;;;;;;OAOG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEtC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAElB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAEtD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,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IAEM,CAAE,YAAY;QACrB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;CACF;AAjVD,sBAiVC;AAED;;;;;GAKG;AACH,MAAa,eAAyB,SAAQ,8BAAmB;IAC/D;;;OAGG;IACH,OAAO,CAAC,KAAQ;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,QAAQ;;QACN,OAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF;AAhCD,0CAgCC"}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../src/data-structures/queue/queue.ts"],"names":[],"mappings":";;;AAMA,kCAA8C;AAC9C,gDAAkD;AAElD;;;;;;;;GAQG;AACH,MAAa,KAAe,SAAQ,0BAAsB;IACxD;;;;;OAKG;IACH,YAAY,QAAc;QACxB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,QAAQ,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAID,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC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AhCD,0CAgCC"}
@@ -73,7 +73,7 @@ export declare class Stack<E = any> extends IterableElementBase<E> {
73
73
  * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
74
74
  * @returns The `push` method is returning the updated `Stack<E>` object.
75
75
  */
76
- push(element: E): Stack<E>;
76
+ push(element: E): boolean;
77
77
  /**
78
78
  * Time Complexity: O(1), as it only involves accessing the last element of the array.
79
79
  * Space Complexity: O(1), as it does not use any additional space.
@@ -154,10 +154,9 @@ export declare class Stack<E = any> extends IterableElementBase<E> {
154
154
  * @returns The `map` method is returning a new `Stack` object.
155
155
  */
156
156
  map<T>(callback: ElementCallback<E, T>, thisArg?: any): Stack<T>;
157
- print(): void;
158
157
  /**
159
158
  * Custom iterator for the Stack class.
160
159
  * @returns An iterator object.
161
160
  */
162
- protected _getIterator(): Generator<E, void, unknown>;
161
+ protected _getIterator(): IterableIterator<E>;
163
162
  }
@@ -89,7 +89,7 @@ class Stack extends base_1.IterableElementBase {
89
89
  */
90
90
  push(element) {
91
91
  this.elements.push(element);
92
- return this;
92
+ return true;
93
93
  }
94
94
  /**
95
95
  * Time Complexity: O(1), as it only involves accessing the last element of the array.
@@ -105,7 +105,7 @@ class Stack extends base_1.IterableElementBase {
105
105
  */
106
106
  pop() {
107
107
  if (this.isEmpty())
108
- return undefined;
108
+ return;
109
109
  return this.elements.pop();
110
110
  }
111
111
  /**
@@ -199,9 +199,6 @@ class Stack extends base_1.IterableElementBase {
199
199
  }
200
200
  return newStack;
201
201
  }
202
- print() {
203
- console.log([...this]);
204
- }
205
202
  /**
206
203
  * Custom iterator for the Stack class.
207
204
  * @returns An iterator object.
@@ -1 +1 @@
1
- {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../../src/data-structures/stack/stack.ts"],"names":[],"mappings":";;;AAQA,kCAA8C;AAE9C;;;;;;;GAOG;AACH,MAAa,KAAe,SAAQ,0BAAsB;IACxD;;;;;OAKG;IACH,YAAY,QAAsB;QAChC,KAAK,EAAE,CAAC;QACR,I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AAI,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACM,CAAE,YAAY;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AA7ND,sBA6NC"}
@@ -172,7 +172,7 @@ export declare class Trie extends IterableElementBase<string> {
172
172
  * specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
173
173
  * @returns The `filter` method is returning an array of strings (`string[]`).
174
174
  */
175
- filter(predicate: ElementCallback<string, boolean>, thisArg?: any): string[];
175
+ filter(predicate: ElementCallback<string, boolean>, thisArg?: any): Trie;
176
176
  /**
177
177
  * Time Complexity: O(n)
178
178
  * Space Complexity: O(n)
@@ -191,7 +191,6 @@ export declare class Trie extends IterableElementBase<string> {
191
191
  * @returns The `map` function is returning a new Trie object.
192
192
  */
193
193
  map(callback: ElementCallback<string, string>, thisArg?: any): Trie;
194
- print(): void;
195
194
  protected _getIterator(): IterableIterator<string>;
196
195
  /**
197
196
  * Time Complexity: O(M), where M is the length of the input string.
@@ -341,11 +341,11 @@ class Trie extends base_1.IterableElementBase {
341
341
  * @returns The `filter` method is returning an array of strings (`string[]`).
342
342
  */
343
343
  filter(predicate, thisArg) {
344
- const results = [];
344
+ const results = new Trie();
345
345
  let index = 0;
346
346
  for (const word of this) {
347
347
  if (predicate.call(thisArg, word, index, this)) {
348
- results.push(word);
348
+ results.add(word);
349
349
  }
350
350
  index++;
351
351
  }
@@ -377,9 +377,6 @@ class Trie extends base_1.IterableElementBase {
377
377
  }
378
378
  return newTrie;
379
379
  }
380
- print() {
381
- console.log([...this]);
382
- }
383
380
  *_getIterator() {
384
381
  function* _dfs(node, path) {
385
382
  if (node.isEnd) {
@@ -1 +1 @@
1
- {"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/data-structures/trie/trie.ts"],"names":[],"mappings":";;;AAQA,kCAA8C;AAE9C;;;GAGG;AACH,MAAa,QAAQ;IAKnB,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC9C,CAAC;CACF;AAVD,4BAUC;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,IAAK,SAAQ,0BAA2B;IACnD,YAAY,KAAgB,EAAE,aAAa,GAAG,IAAI;QAChD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAID,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAID,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAID,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IAEH;;;;;;;OAOG;IACH,GAAG,CAAC,IAAY;QACd,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QACpB,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,MAAM,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,CAAC;YACvD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,CAAE,YAAY;QACrB,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAc,EAAE,IAAY;YACzC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC;YACb,CAAC;YACD,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC9C,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IAEH;;;;;;OAMG;IACO,YAAY,CAAC,GAAW;QAChC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,+CAA+C;QAC1E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArZD,oBAqZC"}
@@ -126,6 +126,12 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
126
126
  * all the elements in the collection.
127
127
  */
128
128
  reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U;
129
+ hasValue(value: V): boolean;
130
+ /**
131
+ * Time Complexity: O(n)
132
+ * Space Complexity: O(n)
133
+ */
134
+ print(): void;
129
135
  protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
130
136
  }
131
137
  export declare abstract class IterableElementBase<V> {
@@ -228,5 +234,10 @@ export declare abstract class IterableElementBase<V> {
228
234
  * all the elements in the array and applying the callback function to each element.
229
235
  */
230
236
  reduce<U>(callbackfn: ReduceElementCallback<V, U>, initialValue: U): U;
237
+ /**
238
+ * Time Complexity: O(n)
239
+ * Space Complexity: O(n)
240
+ */
241
+ print(): void;
231
242
  protected abstract _getIterator(...args: any[]): IterableIterator<V>;
232
243
  }
@@ -169,6 +169,20 @@ export class IterableEntryBase {
169
169
  }
170
170
  return accumulator;
171
171
  }
172
+ hasValue(value) {
173
+ for (const [, elementValue] of this) {
174
+ if (elementValue === value)
175
+ return true;
176
+ }
177
+ return false;
178
+ }
179
+ /**
180
+ * Time Complexity: O(n)
181
+ * Space Complexity: O(n)
182
+ */
183
+ print() {
184
+ console.log([...this]);
185
+ }
172
186
  }
173
187
  export class IterableElementBase {
174
188
  /**
@@ -304,4 +318,11 @@ export class IterableElementBase {
304
318
  }
305
319
  return accumulator;
306
320
  }
321
+ /**
322
+ * Time Complexity: O(n)
323
+ * Space Complexity: O(n)
324
+ */
325
+ print() {
326
+ console.log([...this]);
327
+ }
307
328
  }
@@ -432,11 +432,6 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
432
432
  * type `number`.
433
433
  */
434
434
  getLowMap(): Map<VO, number>;
435
- /**
436
- * The function `getCycles` returns a map of cycles found using the Tarjan algorithm.
437
- * @returns The function `getCycles()` is returning a `Map<number, VO[]>`.
438
- */
439
- getCycles(): Map<number, VO[]>;
440
435
  /**
441
436
  * The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.
442
437
  * @returns an array of VO objects, specifically the cut vertexes.
@@ -453,6 +448,11 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
453
448
  * @returns the bridges found using the Tarjan algorithm.
454
449
  */
455
450
  getBridges(): EO[];
451
+ /**
452
+ * O(V+E+C)
453
+ * O(V+C)
454
+ */
455
+ getCycles(isInclude2Cycle?: boolean): VertexKey[][];
456
456
  /**
457
457
  * Time Complexity: O(n)
458
458
  * Space Complexity: O(n)
@@ -493,8 +493,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
493
493
  */
494
494
  map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
495
495
  protected _getIterator(): IterableIterator<[VertexKey, V | undefined]>;
496
- protected abstract _addEdgeOnly(edge: EO): boolean;
497
- protected _addVertexOnly(newVertex: VO): boolean;
496
+ protected abstract _addEdge(edge: EO): boolean;
497
+ protected _addVertex(newVertex: VO): boolean;
498
498
  protected _getVertex(vertexOrKey: VertexKey | VO): VO | undefined;
499
499
  protected _getVertexKey(vertexOrKey: VO | VertexKey): VertexKey;
500
500
  }