data-structure-typed 1.49.6 → 1.49.8

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 (198) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +16 -13
  3. package/README_zh-CN.md +2 -0
  4. package/benchmark/report.html +13 -13
  5. package/benchmark/report.json +148 -148
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +3 -3
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js +5 -5
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +3 -3
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js +11 -13
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/bst.d.ts +3 -3
  13. package/dist/cjs/data-structures/binary-tree/bst.js +6 -7
  14. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js +6 -6
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +3 -3
  20. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  21. package/dist/cjs/data-structures/hash/hash-map.d.ts +24 -27
  22. package/dist/cjs/data-structures/hash/hash-map.js +35 -35
  23. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  24. package/dist/cjs/data-structures/hash/index.d.ts +0 -1
  25. package/dist/cjs/data-structures/hash/index.js +0 -1
  26. package/dist/cjs/data-structures/hash/index.js.map +1 -1
  27. package/dist/cjs/data-structures/heap/heap.d.ts +2 -1
  28. package/dist/cjs/data-structures/heap/heap.js +13 -13
  29. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  30. package/dist/cjs/data-structures/heap/max-heap.js +1 -1
  31. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  32. package/dist/cjs/data-structures/heap/min-heap.js +1 -1
  33. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  34. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +1 -1
  35. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  36. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +1 -3
  37. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  38. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -8
  39. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +15 -18
  40. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  41. package/dist/cjs/data-structures/matrix/matrix.d.ts +2 -7
  42. package/dist/cjs/data-structures/matrix/matrix.js +0 -7
  43. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  44. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +1 -1
  45. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  46. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +1 -1
  47. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  48. package/dist/cjs/data-structures/priority-queue/priority-queue.js +1 -1
  49. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  50. package/dist/cjs/data-structures/queue/deque.d.ts +2 -11
  51. package/dist/cjs/data-structures/queue/deque.js +9 -13
  52. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  53. package/dist/cjs/data-structures/queue/queue.d.ts +13 -13
  54. package/dist/cjs/data-structures/queue/queue.js +29 -25
  55. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  56. package/dist/cjs/data-structures/stack/stack.js +2 -3
  57. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  58. package/dist/cjs/data-structures/trie/trie.d.ts +2 -2
  59. package/dist/cjs/data-structures/trie/trie.js +9 -5
  60. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  61. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -2
  62. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +1 -1
  63. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
  64. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  65. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +5 -2
  66. package/dist/cjs/types/data-structures/hash/index.d.ts +0 -1
  67. package/dist/cjs/types/data-structures/hash/index.js +0 -1
  68. package/dist/cjs/types/data-structures/hash/index.js.map +1 -1
  69. package/dist/cjs/types/data-structures/heap/heap.d.ts +1 -1
  70. package/dist/cjs/types/data-structures/linked-list/index.d.ts +1 -0
  71. package/dist/cjs/types/data-structures/linked-list/index.js +1 -0
  72. package/dist/cjs/types/data-structures/linked-list/index.js.map +1 -1
  73. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.d.ts +4 -1
  74. package/dist/cjs/types/data-structures/matrix/index.d.ts +1 -0
  75. package/dist/cjs/types/data-structures/matrix/index.js +1 -0
  76. package/dist/cjs/types/data-structures/matrix/index.js.map +1 -1
  77. package/dist/cjs/types/data-structures/matrix/matrix.d.ts +7 -1
  78. package/dist/cjs/types/data-structures/queue/deque.d.ts +3 -1
  79. package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -1
  80. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +3 -3
  81. package/dist/mjs/data-structures/binary-tree/avl-tree.js +5 -5
  82. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +3 -3
  83. package/dist/mjs/data-structures/binary-tree/binary-tree.js +11 -13
  84. package/dist/mjs/data-structures/binary-tree/bst.d.ts +3 -3
  85. package/dist/mjs/data-structures/binary-tree/bst.js +6 -7
  86. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  87. package/dist/mjs/data-structures/binary-tree/rb-tree.js +5 -6
  88. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  89. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +3 -3
  90. package/dist/mjs/data-structures/hash/hash-map.d.ts +24 -27
  91. package/dist/mjs/data-structures/hash/hash-map.js +35 -37
  92. package/dist/mjs/data-structures/hash/index.d.ts +0 -1
  93. package/dist/mjs/data-structures/hash/index.js +0 -1
  94. package/dist/mjs/data-structures/heap/heap.d.ts +2 -1
  95. package/dist/mjs/data-structures/heap/heap.js +19 -20
  96. package/dist/mjs/data-structures/heap/max-heap.js +1 -1
  97. package/dist/mjs/data-structures/heap/min-heap.js +1 -1
  98. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +1 -1
  99. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -5
  100. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -8
  101. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +16 -23
  102. package/dist/mjs/data-structures/matrix/matrix.d.ts +2 -7
  103. package/dist/mjs/data-structures/matrix/matrix.js +0 -7
  104. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +1 -1
  105. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +1 -1
  106. package/dist/mjs/data-structures/priority-queue/priority-queue.js +1 -1
  107. package/dist/mjs/data-structures/queue/deque.d.ts +2 -11
  108. package/dist/mjs/data-structures/queue/deque.js +9 -14
  109. package/dist/mjs/data-structures/queue/queue.d.ts +13 -13
  110. package/dist/mjs/data-structures/queue/queue.js +30 -28
  111. package/dist/mjs/data-structures/stack/stack.js +3 -5
  112. package/dist/mjs/data-structures/trie/trie.d.ts +2 -2
  113. package/dist/mjs/data-structures/trie/trie.js +10 -9
  114. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -2
  115. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +1 -1
  116. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
  117. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  118. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +5 -2
  119. package/dist/mjs/types/data-structures/hash/index.d.ts +0 -1
  120. package/dist/mjs/types/data-structures/hash/index.js +0 -1
  121. package/dist/mjs/types/data-structures/heap/heap.d.ts +1 -1
  122. package/dist/mjs/types/data-structures/linked-list/index.d.ts +1 -0
  123. package/dist/mjs/types/data-structures/linked-list/index.js +1 -0
  124. package/dist/mjs/types/data-structures/linked-list/skip-linked-list.d.ts +4 -1
  125. package/dist/mjs/types/data-structures/matrix/index.d.ts +1 -0
  126. package/dist/mjs/types/data-structures/matrix/index.js +1 -0
  127. package/dist/mjs/types/data-structures/matrix/matrix.d.ts +7 -1
  128. package/dist/mjs/types/data-structures/queue/deque.d.ts +3 -1
  129. package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -1
  130. package/dist/umd/data-structure-typed.js +151 -432
  131. package/dist/umd/data-structure-typed.min.js +2 -2
  132. package/dist/umd/data-structure-typed.min.js.map +1 -1
  133. package/package.json +1 -1
  134. package/src/data-structures/binary-tree/avl-tree.ts +4 -4
  135. package/src/data-structures/binary-tree/binary-tree.ts +10 -14
  136. package/src/data-structures/binary-tree/bst.ts +5 -7
  137. package/src/data-structures/binary-tree/rb-tree.ts +4 -5
  138. package/src/data-structures/binary-tree/tree-multimap.ts +2 -2
  139. package/src/data-structures/hash/hash-map.ts +46 -50
  140. package/src/data-structures/hash/index.ts +0 -1
  141. package/src/data-structures/heap/heap.ts +20 -19
  142. package/src/data-structures/heap/max-heap.ts +1 -1
  143. package/src/data-structures/heap/min-heap.ts +1 -1
  144. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  145. package/src/data-structures/linked-list/singly-linked-list.ts +2 -5
  146. package/src/data-structures/linked-list/skip-linked-list.ts +15 -16
  147. package/src/data-structures/matrix/matrix.ts +2 -10
  148. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  149. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  150. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  151. package/src/data-structures/queue/deque.ts +11 -15
  152. package/src/data-structures/queue/queue.ts +29 -28
  153. package/src/data-structures/stack/stack.ts +3 -6
  154. package/src/data-structures/trie/trie.ts +10 -11
  155. package/src/types/data-structures/binary-tree/binary-tree.ts +2 -2
  156. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  157. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
  158. package/src/types/data-structures/binary-tree/tree-multimap.ts +1 -1
  159. package/src/types/data-structures/hash/hash-map.ts +6 -2
  160. package/src/types/data-structures/hash/index.ts +0 -1
  161. package/src/types/data-structures/heap/heap.ts +1 -1
  162. package/src/types/data-structures/linked-list/index.ts +1 -0
  163. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -1
  164. package/src/types/data-structures/matrix/index.ts +1 -0
  165. package/src/types/data-structures/matrix/matrix.ts +7 -1
  166. package/src/types/data-structures/queue/deque.ts +1 -1
  167. package/src/types/data-structures/trie/trie.ts +1 -1
  168. package/test/integration/index.html +4 -4
  169. package/test/unit/data-structures/binary-tree/overall.test.ts +180 -1
  170. package/test/unit/data-structures/hash/hash-map.test.ts +19 -6
  171. package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
  172. package/test/unit/data-structures/queue/deque.test.ts +5 -5
  173. package/test/unit/data-structures/trie/trie.test.ts +1 -1
  174. package/dist/cjs/data-structures/hash/hash-table.d.ts +0 -108
  175. package/dist/cjs/data-structures/hash/hash-table.js +0 -282
  176. package/dist/cjs/data-structures/hash/hash-table.js.map +0 -1
  177. package/dist/cjs/types/data-structures/hash/hash-table.d.ts +0 -1
  178. package/dist/cjs/types/data-structures/hash/hash-table.js +0 -3
  179. package/dist/cjs/types/data-structures/hash/hash-table.js.map +0 -1
  180. package/dist/cjs/types/data-structures/matrix/matrix2d.d.ts +0 -1
  181. package/dist/cjs/types/data-structures/matrix/matrix2d.js +0 -3
  182. package/dist/cjs/types/data-structures/matrix/matrix2d.js.map +0 -1
  183. package/dist/cjs/types/data-structures/matrix/vector2d.d.ts +0 -1
  184. package/dist/cjs/types/data-structures/matrix/vector2d.js +0 -3
  185. package/dist/cjs/types/data-structures/matrix/vector2d.js.map +0 -1
  186. package/dist/mjs/data-structures/hash/hash-table.d.ts +0 -108
  187. package/dist/mjs/data-structures/hash/hash-table.js +0 -283
  188. package/dist/mjs/types/data-structures/hash/hash-table.d.ts +0 -1
  189. package/dist/mjs/types/data-structures/hash/hash-table.js +0 -1
  190. package/dist/mjs/types/data-structures/matrix/matrix2d.d.ts +0 -1
  191. package/dist/mjs/types/data-structures/matrix/matrix2d.js +0 -1
  192. package/dist/mjs/types/data-structures/matrix/vector2d.d.ts +0 -1
  193. package/dist/mjs/types/data-structures/matrix/vector2d.js +0 -1
  194. package/src/data-structures/hash/hash-table.ts +0 -318
  195. package/src/types/data-structures/hash/hash-table.ts +0 -1
  196. package/src/types/data-structures/matrix/matrix2d.ts +0 -1
  197. package/src/types/data-structures/matrix/vector2d.ts +0 -1
  198. package/test/unit/data-structures/hash/hash-table.test.ts +0 -238
@@ -5,6 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
+ import type { MatrixOptions } from '../../types';
8
9
  export declare class Matrix {
9
10
  /**
10
11
  * The constructor function initializes a matrix object with the provided data and options, or with
@@ -13,13 +14,7 @@ export declare class Matrix {
13
14
  * @param [options] - The `options` parameter is an optional object that can contain the following
14
15
  * properties:
15
16
  */
16
- constructor(data: number[][], options?: {
17
- rows?: number;
18
- cols?: number;
19
- addFn?: (a: number, b: number) => any;
20
- subtractFn?: (a: number, b: number) => any;
21
- multiplyFn?: (a: number, b: number) => any;
22
- });
17
+ constructor(data: number[][], options?: MatrixOptions);
23
18
  protected _rows: number;
24
19
  get rows(): number;
25
20
  protected _cols: number;
@@ -1,10 +1,3 @@
1
- /**
2
- * data-structure-typed
3
- *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT License
7
- */
8
1
  export class Matrix {
9
2
  /**
10
3
  * The constructor function initializes a matrix object with the provided data and options, or with
@@ -1,6 +1,6 @@
1
1
  import { PriorityQueue } from './priority-queue';
2
2
  export class MaxPriorityQueue extends PriorityQueue {
3
- constructor(elements, options = {
3
+ constructor(elements = [], options = {
4
4
  comparator: (a, b) => {
5
5
  if (!(typeof a === 'number' && typeof b === 'number')) {
6
6
  throw new Error('The a, b params of compare function must be number');
@@ -1,6 +1,6 @@
1
1
  import { PriorityQueue } from './priority-queue';
2
2
  export class MinPriorityQueue extends PriorityQueue {
3
- constructor(elements, options = {
3
+ constructor(elements = [], options = {
4
4
  comparator: (a, b) => {
5
5
  if (!(typeof a === 'number' && typeof b === 'number')) {
6
6
  throw new Error('The a, b params of compare function must be number');
@@ -8,7 +8,7 @@ import { Heap } from '../heap';
8
8
  * 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
9
9
  */
10
10
  export class PriorityQueue extends Heap {
11
- constructor(elements, options) {
11
+ constructor(elements = [], options) {
12
12
  super(elements, options);
13
13
  }
14
14
  }
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { ElementCallback, IterableWithSizeOrLength } from '../../types';
8
+ import type { DequeOptions, ElementCallback, IterableWithSizeOrLength } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
10
  /**
11
11
  * 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
@@ -21,16 +21,7 @@ export declare class Deque<E> extends IterableElementBase<E> {
21
21
  protected _lastInBucket: number;
22
22
  protected _bucketCount: number;
23
23
  protected readonly _bucketSize: number;
24
- /**
25
- * The constructor initializes a data structure with a specified bucket size and populates it with
26
- * elements from an iterable.
27
- * @param elements - The `elements` parameter is an iterable object (such as an array or a Set) that
28
- * contains the initial elements to be stored in the data structure. It can also be an object with a
29
- * `length` property or a `size` property, which represents the number of elements in the iterable.
30
- * @param bucketSize - The `bucketSize` parameter is the maximum number of elements that can be
31
- * stored in each bucket. It determines the size of each bucket in the data structure.
32
- */
33
- constructor(elements?: IterableWithSizeOrLength<E>, bucketSize?: number);
24
+ constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
34
25
  protected _buckets: E[][];
35
26
  get buckets(): E[][];
36
27
  protected _size: number;
@@ -13,18 +13,14 @@ export class Deque extends IterableElementBase {
13
13
  _bucketLast = 0;
14
14
  _lastInBucket = 0;
15
15
  _bucketCount = 0;
16
- _bucketSize;
17
- /**
18
- * The constructor initializes a data structure with a specified bucket size and populates it with
19
- * elements from an iterable.
20
- * @param elements - The `elements` parameter is an iterable object (such as an array or a Set) that
21
- * contains the initial elements to be stored in the data structure. It can also be an object with a
22
- * `length` property or a `size` property, which represents the number of elements in the iterable.
23
- * @param bucketSize - The `bucketSize` parameter is the maximum number of elements that can be
24
- * stored in each bucket. It determines the size of each bucket in the data structure.
25
- */
26
- constructor(elements = [], bucketSize = 1 << 12) {
16
+ _bucketSize = 1 << 12;
17
+ constructor(elements = [], options) {
27
18
  super();
19
+ if (options) {
20
+ const { bucketSize } = options;
21
+ if (typeof bucketSize === 'number')
22
+ this._bucketSize = bucketSize;
23
+ }
28
24
  let _size;
29
25
  if ('length' in elements) {
30
26
  if (elements.length instanceof Function)
@@ -38,7 +34,6 @@ export class Deque extends IterableElementBase {
38
34
  else
39
35
  _size = elements.size;
40
36
  }
41
- this._bucketSize = bucketSize;
42
37
  this._bucketCount = calcMinUnitsRequired(_size, this._bucketSize) || 1;
43
38
  for (let i = 0; i < this._bucketCount; ++i) {
44
39
  this._buckets.push(new Array(this._bucketSize));
@@ -610,7 +605,7 @@ export class Deque extends IterableElementBase {
610
605
  * satisfy the given predicate function.
611
606
  */
612
607
  filter(predicate, thisArg) {
613
- const newDeque = new Deque([], this._bucketSize);
608
+ const newDeque = new Deque([], { bucketSize: this._bucketSize });
614
609
  let index = 0;
615
610
  for (const el of this) {
616
611
  if (predicate.call(thisArg, el, index, this)) {
@@ -638,7 +633,7 @@ export class Deque extends IterableElementBase {
638
633
  * @returns a new Deque object with the mapped values.
639
634
  */
640
635
  map(callback, thisArg) {
641
- const newDeque = new Deque([], this._bucketSize);
636
+ const newDeque = new Deque([], { bucketSize: this._bucketSize });
642
637
  let index = 0;
643
638
  for (const el of this) {
644
639
  newDeque.push(callback.call(thisArg, el, index, this));
@@ -12,19 +12,19 @@ import { SinglyLinkedList } from '../linked-list';
12
12
  * 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
13
13
  * 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
14
14
  * 5. Data Buffering: Acting as a buffer for data packets in network communication.
15
- * 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store nodes that are to be visited.
15
+ * 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
16
16
  * 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
17
17
  */
18
18
  export declare class Queue<E = any> extends IterableElementBase<E> {
19
19
  /**
20
20
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
21
21
  * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
22
- * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
22
+ * will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
23
23
  * initialized as an empty array.
24
24
  */
25
- constructor(elements?: E[]);
26
- protected _nodes: E[];
27
- get nodes(): E[];
25
+ constructor(elements?: Iterable<E>);
26
+ protected _elements: E[];
27
+ get elements(): E[];
28
28
  protected _offset: number;
29
29
  get offset(): number;
30
30
  /**
@@ -36,8 +36,8 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
36
36
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
37
37
  * Space Complexity: O(1) - no additional space is used.
38
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
39
+ * The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
40
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
41
41
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
42
42
  */
43
43
  get first(): E | undefined;
@@ -50,7 +50,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
50
50
  * Space Complexity: O(1) - no additional space is used.
51
51
  *
52
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
53
+ * @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
54
54
  * array is empty, it returns `undefined`.
55
55
  */
56
56
  get last(): E | undefined;
@@ -101,8 +101,8 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
101
101
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
102
102
  * Space Complexity: O(1) - no additional space is used.
103
103
  *
104
- * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
105
- * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
104
+ * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
105
+ * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
106
106
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
107
107
  */
108
108
  peek(): E | undefined;
@@ -115,7 +115,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
115
115
  * Space Complexity: O(1) - no additional space is used.
116
116
  *
117
117
  * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
118
- * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
118
+ * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
119
119
  * array is empty, it returns `undefined`.
120
120
  */
121
121
  peekLast(): E | undefined;
@@ -174,12 +174,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
174
174
  * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
175
175
  * Space Complexity: O(n) - where n is the number of elements in the queue.
176
176
  *
177
- * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
177
+ * The toArray() function returns an array of elements from the current offset to the end of the _elements array.
178
178
  * @returns An array of type E is being returned.
179
179
  */
180
180
  toArray(): E[];
181
181
  /**
182
- * The clear function resets the nodes array and offset to their initial values.
182
+ * The clear function resets the elements array and offset to their initial values.
183
183
  */
184
184
  clear(): void;
185
185
  /**
@@ -6,26 +6,28 @@ import { SinglyLinkedList } from '../linked-list';
6
6
  * 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
7
7
  * 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
8
8
  * 5. Data Buffering: Acting as a buffer for data packets in network communication.
9
- * 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store nodes that are to be visited.
9
+ * 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
10
10
  * 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
11
11
  */
12
12
  export class Queue extends IterableElementBase {
13
13
  /**
14
14
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
15
15
  * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
16
- * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
16
+ * will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
17
17
  * initialized as an empty array.
18
18
  */
19
- constructor(elements) {
19
+ constructor(elements = []) {
20
20
  super();
21
- this._nodes = elements || [];
22
- this._offset = 0;
21
+ if (elements) {
22
+ for (const el of elements)
23
+ this.push(el);
24
+ }
23
25
  }
24
- _nodes;
25
- get nodes() {
26
- return this._nodes;
26
+ _elements = [];
27
+ get elements() {
28
+ return this._elements;
27
29
  }
28
- _offset;
30
+ _offset = 0;
29
31
  get offset() {
30
32
  return this._offset;
31
33
  }
@@ -34,18 +36,18 @@ export class Queue extends IterableElementBase {
34
36
  * @returns {number} The size of the array, which is the difference between the length of the array and the offset.
35
37
  */
36
38
  get size() {
37
- return this.nodes.length - this.offset;
39
+ return this.elements.length - this.offset;
38
40
  }
39
41
  /**
40
42
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
41
43
  * Space Complexity: O(1) - no additional space is used.
42
44
  *
43
- * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
44
- * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
45
+ * The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
46
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
45
47
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
46
48
  */
47
49
  get first() {
48
- return this.size > 0 ? this.nodes[this.offset] : undefined;
50
+ return this.size > 0 ? this.elements[this.offset] : undefined;
49
51
  }
50
52
  /**
51
53
  * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
@@ -56,11 +58,11 @@ export class Queue extends IterableElementBase {
56
58
  * Space Complexity: O(1) - no additional space is used.
57
59
  *
58
60
  * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
59
- * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
61
+ * @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
60
62
  * array is empty, it returns `undefined`.
61
63
  */
62
64
  get last() {
63
- return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
65
+ return this.size > 0 ? this.elements[this.elements.length - 1] : undefined;
64
66
  }
65
67
  /**
66
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.
@@ -90,7 +92,7 @@ export class Queue extends IterableElementBase {
90
92
  * @returns The `add` method is returning a `Queue<E>` object.
91
93
  */
92
94
  push(element) {
93
- this.nodes.push(element);
95
+ this.elements.push(element);
94
96
  return true;
95
97
  }
96
98
  /**
@@ -110,11 +112,11 @@ export class Queue extends IterableElementBase {
110
112
  return undefined;
111
113
  const first = this.first;
112
114
  this._offset += 1;
113
- if (this.offset * 2 < this.nodes.length)
115
+ if (this.offset * 2 < this.elements.length)
114
116
  return first;
115
117
  // only delete dequeued elements when reaching half size
116
118
  // to decrease latency of shifting elements.
117
- this._nodes = this.nodes.slice(this.offset);
119
+ this._elements = this.elements.slice(this.offset);
118
120
  this._offset = 0;
119
121
  return first;
120
122
  }
@@ -126,8 +128,8 @@ export class Queue extends IterableElementBase {
126
128
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
127
129
  * Space Complexity: O(1) - no additional space is used.
128
130
  *
129
- * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
130
- * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
131
+ * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
132
+ * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
131
133
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
132
134
  */
133
135
  peek() {
@@ -142,7 +144,7 @@ export class Queue extends IterableElementBase {
142
144
  * Space Complexity: O(1) - no additional space is used.
143
145
  *
144
146
  * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
145
- * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
147
+ * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
146
148
  * array is empty, it returns `undefined`.
147
149
  */
148
150
  peekLast() {
@@ -187,7 +189,7 @@ export class Queue extends IterableElementBase {
187
189
  * @param index
188
190
  */
189
191
  getAt(index) {
190
- return this.nodes[index];
192
+ return this.elements[index];
191
193
  }
192
194
  /**
193
195
  * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
@@ -211,17 +213,17 @@ export class Queue extends IterableElementBase {
211
213
  * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
212
214
  * Space Complexity: O(n) - where n is the number of elements in the queue.
213
215
  *
214
- * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
216
+ * The toArray() function returns an array of elements from the current offset to the end of the _elements array.
215
217
  * @returns An array of type E is being returned.
216
218
  */
217
219
  toArray() {
218
- return this.nodes.slice(this.offset);
220
+ return this.elements.slice(this.offset);
219
221
  }
220
222
  /**
221
- * The clear function resets the nodes array and offset to their initial values.
223
+ * The clear function resets the elements array and offset to their initial values.
222
224
  */
223
225
  clear() {
224
- this._nodes = [];
226
+ this._elements = [];
225
227
  this._offset = 0;
226
228
  }
227
229
  /**
@@ -236,7 +238,7 @@ export class Queue extends IterableElementBase {
236
238
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
237
239
  */
238
240
  clone() {
239
- return new Queue(this.nodes.slice(this.offset));
241
+ return new Queue(this.elements.slice(this.offset));
240
242
  }
241
243
  /**
242
244
  * Time Complexity: O(n)
@@ -301,7 +303,7 @@ export class Queue extends IterableElementBase {
301
303
  * Space Complexity: O(n)
302
304
  */
303
305
  *_getIterator() {
304
- for (const item of this.nodes) {
306
+ for (const item of this.elements) {
305
307
  yield item;
306
308
  }
307
309
  }
@@ -14,16 +14,14 @@ export class Stack extends IterableElementBase {
14
14
  * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
15
15
  * is provided and is an array, it is assigned to the `_elements
16
16
  */
17
- constructor(elements) {
17
+ constructor(elements = []) {
18
18
  super();
19
- this._elements = [];
20
19
  if (elements) {
21
- for (const el of elements) {
20
+ for (const el of elements)
22
21
  this.push(el);
23
- }
24
22
  }
25
23
  }
26
- _elements;
24
+ _elements = [];
27
25
  get elements() {
28
26
  return this._elements;
29
27
  }
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { ElementCallback } from '../../types';
8
+ import type { ElementCallback, TrieOptions } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
10
  /**
11
11
  * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
@@ -31,7 +31,7 @@ export declare class TrieNode {
31
31
  * 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
32
32
  */
33
33
  export declare class Trie extends IterableElementBase<string> {
34
- constructor(words?: string[], caseSensitive?: boolean);
34
+ constructor(words?: Iterable<string>, options?: TrieOptions);
35
35
  protected _size: number;
36
36
  get size(): number;
37
37
  protected _caseSensitive: boolean;
@@ -27,26 +27,27 @@ export class TrieNode {
27
27
  * 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
28
28
  */
29
29
  export class Trie extends IterableElementBase {
30
- constructor(words, caseSensitive = true) {
30
+ constructor(words = [], options) {
31
31
  super();
32
- this._root = new TrieNode('');
33
- this._caseSensitive = caseSensitive;
34
- this._size = 0;
32
+ if (options) {
33
+ const { caseSensitive } = options;
34
+ if (caseSensitive !== undefined)
35
+ this._caseSensitive = caseSensitive;
36
+ }
35
37
  if (words) {
36
- for (const word of words) {
38
+ for (const word of words)
37
39
  this.add(word);
38
- }
39
40
  }
40
41
  }
41
- _size;
42
+ _size = 0;
42
43
  get size() {
43
44
  return this._size;
44
45
  }
45
- _caseSensitive;
46
+ _caseSensitive = true;
46
47
  get caseSensitive() {
47
48
  return this._caseSensitive;
48
49
  }
49
- _root;
50
+ _root = new TrieNode('');
50
51
  get root() {
51
52
  return this._root;
52
53
  }
@@ -3,6 +3,6 @@ import { IterationType } from "../../common";
3
3
  export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
4
  export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
5
  export type BinaryTreeOptions<K> = {
6
- iterationType: IterationType;
7
- extractor: (key: K) => number;
6
+ iterationType?: IterationType;
7
+ extractor?: (key: K) => number;
8
8
  };
@@ -4,5 +4,5 @@ import { BSTVariant } from "../../common";
4
4
  export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
5
  export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
6
  export type BSTOptions<K> = BinaryTreeOptions<K> & {
7
- variant: BSTVariant;
7
+ variant?: BSTVariant;
8
8
  };
@@ -6,4 +6,4 @@ export declare enum RBTNColor {
6
6
  }
7
7
  export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
8
  export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
9
- export type RBTreeOptions<K> = BSTOptions<K> & {};
9
+ export type RBTreeOptions<K> = Omit<BSTOptions<K>, 'variant'> & {};
@@ -2,4 +2,4 @@ import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
2
2
  import type { AVLTreeOptions } from './avl-tree';
3
3
  export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
4
  export type TreeMultimapNested<K, V, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type TreeMultimapOptions<K> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {};
5
+ export type TreeMultimapOptions<K> = AVLTreeOptions<K> & {};
@@ -4,9 +4,12 @@ export type HashMapLinkedNode<K, V> = {
4
4
  next: HashMapLinkedNode<K, V>;
5
5
  prev: HashMapLinkedNode<K, V>;
6
6
  };
7
+ export type LinkedHashMapOptions<K> = {
8
+ hashFn?: (key: K) => string;
9
+ objHashFn?: (key: K) => object;
10
+ };
7
11
  export type HashMapOptions<K> = {
8
- hashFn: (key: K) => string;
9
- objHashFn: (key: K) => object;
12
+ hashFn?: (key: K) => string;
10
13
  };
11
14
  export type HashMapStoreItem<K, V> = {
12
15
  key: K;
@@ -1,3 +1,2 @@
1
1
  export * from './hash-map';
2
- export * from './hash-table';
3
2
  export type HashFunction<K> = (key: K) => number;
@@ -1,2 +1 @@
1
1
  export * from './hash-map';
2
- export * from './hash-table';
@@ -1,4 +1,4 @@
1
1
  import { Comparator } from '../../common';
2
2
  export type HeapOptions<T> = {
3
- comparator: Comparator<T>;
3
+ comparator?: Comparator<T>;
4
4
  };
@@ -1,2 +1,3 @@
1
1
  export * from './singly-linked-list';
2
2
  export * from './doubly-linked-list';
3
+ export * from './skip-linked-list';
@@ -1,2 +1,3 @@
1
1
  export * from './singly-linked-list';
2
2
  export * from './doubly-linked-list';
3
+ export * from './skip-linked-list';
@@ -1 +1,4 @@
1
- export {};
1
+ export type SkipLinkedListOptions = {
2
+ maxLevel?: number;
3
+ probability?: number;
4
+ };
@@ -1 +1,2 @@
1
1
  export * from './navigator';
2
+ export * from './matrix';
@@ -1 +1,2 @@
1
1
  export * from './navigator';
2
+ export * from './matrix';
@@ -1 +1,7 @@
1
- export {};
1
+ export type MatrixOptions = {
2
+ rows?: number;
3
+ cols?: number;
4
+ addFn?: (a: number, b: number) => any;
5
+ subtractFn?: (a: number, b: number) => any;
6
+ multiplyFn?: (a: number, b: number) => any;
7
+ };
@@ -1 +1,3 @@
1
- export {};
1
+ export type DequeOptions = {
2
+ bucketSize?: number;
3
+ };
@@ -1 +1,3 @@
1
- export {};
1
+ export type TrieOptions = {
2
+ caseSensitive?: boolean;
3
+ };