data-structure-typed 1.33.0 → 1.33.2

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 (93) hide show
  1. package/.idea/codeStyles/Project.xml +61 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/CHANGELOG.md +1 -1
  4. package/README.md +197 -257
  5. package/coverage/coverage-final.json +63 -63
  6. package/coverage/coverage-summary.json +16 -16
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1 -16
  8. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/avl-tree.js +2 -2
  10. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/rb-tree.js +3 -4
  12. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  13. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  14. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  15. package/dist/data-structures/hash/hash-table.js +107 -2
  16. package/dist/data-structures/hash/hash-table.js.map +1 -1
  17. package/dist/data-structures/heap/max-heap.js.map +1 -1
  18. package/dist/data-structures/heap/min-heap.js.map +1 -1
  19. package/dist/data-structures/linked-list/doubly-linked-list.js +30 -0
  20. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  21. package/dist/data-structures/matrix/matrix2d.js +5 -8
  22. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  23. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  24. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  25. package/dist/data-structures/queue/deque.js.map +1 -1
  26. package/docs/index.html +197 -256
  27. package/docs/modules.html +2 -0
  28. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +8 -18
  29. package/lib/data-structures/binary-tree/abstract-binary-tree.js +5 -23
  30. package/lib/data-structures/binary-tree/avl-tree.d.ts +7 -10
  31. package/lib/data-structures/binary-tree/avl-tree.js +6 -9
  32. package/lib/data-structures/binary-tree/binary-tree.d.ts +2 -2
  33. package/lib/data-structures/binary-tree/bst.d.ts +2 -2
  34. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  35. package/lib/data-structures/binary-tree/rb-tree.js +3 -3
  36. package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
  37. package/lib/data-structures/binary-tree/tree-multiset.js +1 -1
  38. package/lib/data-structures/graph/abstract-graph.d.ts +10 -10
  39. package/lib/data-structures/graph/abstract-graph.js +2 -2
  40. package/lib/data-structures/graph/directed-graph.d.ts +6 -6
  41. package/lib/data-structures/graph/directed-graph.js +2 -2
  42. package/lib/data-structures/graph/map-graph.d.ts +6 -6
  43. package/lib/data-structures/graph/map-graph.js +2 -2
  44. package/lib/data-structures/graph/undirected-graph.d.ts +6 -6
  45. package/lib/data-structures/graph/undirected-graph.js +2 -2
  46. package/lib/data-structures/hash/hash-table.d.ts +61 -1
  47. package/lib/data-structures/hash/hash-table.js +136 -0
  48. package/lib/data-structures/heap/heap.d.ts +31 -31
  49. package/lib/data-structures/heap/heap.js +11 -11
  50. package/lib/data-structures/heap/max-heap.d.ts +4 -4
  51. package/lib/data-structures/heap/max-heap.js +1 -1
  52. package/lib/data-structures/heap/min-heap.d.ts +4 -4
  53. package/lib/data-structures/heap/min-heap.js +1 -1
  54. package/lib/data-structures/linked-list/doubly-linked-list.d.ts +93 -54
  55. package/lib/data-structures/linked-list/doubly-linked-list.js +79 -22
  56. package/lib/data-structures/linked-list/singly-linked-list.d.ts +46 -46
  57. package/lib/data-structures/linked-list/singly-linked-list.js +20 -20
  58. package/lib/data-structures/matrix/matrix.d.ts +3 -3
  59. package/lib/data-structures/matrix/matrix2d.d.ts +1 -1
  60. package/lib/data-structures/matrix/matrix2d.js +3 -2
  61. package/lib/data-structures/priority-queue/max-priority-queue.d.ts +4 -4
  62. package/lib/data-structures/priority-queue/min-priority-queue.d.ts +4 -4
  63. package/lib/data-structures/priority-queue/priority-queue.d.ts +26 -26
  64. package/lib/data-structures/priority-queue/priority-queue.js +8 -8
  65. package/lib/data-structures/queue/deque.d.ts +30 -30
  66. package/lib/data-structures/queue/deque.js +7 -7
  67. package/lib/data-structures/queue/queue.d.ts +27 -27
  68. package/lib/data-structures/queue/queue.js +8 -8
  69. package/lib/data-structures/stack/stack.d.ts +15 -15
  70. package/lib/data-structures/stack/stack.js +6 -6
  71. package/lib/data-structures/tree/tree.d.ts +7 -7
  72. package/lib/interfaces/abstract-binary-tree.d.ts +0 -1
  73. package/lib/interfaces/avl-tree.d.ts +1 -1
  74. package/lib/types/data-structures/navigator.d.ts +1 -1
  75. package/package.json +3 -5
  76. package/test/integration/index.html +6 -6
  77. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +146 -0
  78. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +44 -0
  79. package/test/unit/data-structures/hash/coordinate-map.test.ts +54 -0
  80. package/test/unit/data-structures/hash/coordinate-set.test.ts +41 -0
  81. package/test/unit/data-structures/hash/hash-table.test.ts +97 -0
  82. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -3
  83. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +53 -0
  84. package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
  85. package/test/unit/data-structures/matrix/matrix2d.test.ts +138 -0
  86. package/test/unit/data-structures/matrix/navigator.test.ts +80 -0
  87. package/test/unit/data-structures/queue/deque.test.ts +131 -0
  88. package/test/unit/data-structures/queue/queue.test.ts +168 -1
  89. package/test/unit/data-structures/stack/stack.test.ts +67 -0
  90. package/test/unit/data-structures/tree/tree.test.ts +39 -0
  91. package/test/unit/data-structures/trie/trie.test.ts +95 -0
  92. package/umd/bundle.min.js +1 -1
  93. package/umd/bundle.min.js.map +1 -1
@@ -6,13 +6,13 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { DoublyLinkedList } from '../linked-list';
9
- export declare class Deque<T> extends DoublyLinkedList<T> {
9
+ export declare class Deque<E = any> extends DoublyLinkedList<E> {
10
10
  }
11
- export declare class ObjectDeque<T = number> {
11
+ export declare class ObjectDeque<E = number> {
12
12
  constructor(capacity?: number);
13
13
  private _nodes;
14
14
  get nodes(): {
15
- [p: number]: T;
15
+ [p: number]: E;
16
16
  };
17
17
  private _capacity;
18
18
  get capacity(): number;
@@ -27,35 +27,35 @@ export declare class ObjectDeque<T = number> {
27
27
  get size(): number;
28
28
  /**
29
29
  * The "addFirst" function adds a value to the beginning of an array-like data structure.
30
- * @param {T} value - The `value` parameter represents the value that you want to add to the beginning of the data
30
+ * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
31
31
  * structure.
32
32
  */
33
- addFirst(value: T): void;
33
+ addFirst(value: E): void;
34
34
  /**
35
35
  * The addLast function adds a value to the end of an array-like data structure.
36
- * @param {T} value - The `value` parameter represents the value that you want to add to the end of the data structure.
36
+ * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
37
37
  */
38
- addLast(value: T): void;
38
+ addLast(value: E): void;
39
39
  /**
40
40
  * The function `pollFirst()` removes and returns the first element in a data structure.
41
41
  * @returns The value of the first element in the data structure.
42
42
  */
43
- pollFirst(): T | undefined;
43
+ pollFirst(): E | undefined;
44
44
  /**
45
45
  * The `peekFirst` function returns the first element in an array-like data structure if it exists.
46
46
  * @returns The element at the first position of the `_nodes` array.
47
47
  */
48
- peekFirst(): T | undefined;
48
+ peekFirst(): E | undefined;
49
49
  /**
50
50
  * The `pollLast()` function removes and returns the last element in a data structure.
51
51
  * @returns The value that was removed from the data structure.
52
52
  */
53
- pollLast(): T | undefined;
53
+ pollLast(): E | undefined;
54
54
  /**
55
55
  * The `peekLast()` function returns the last element in an array-like data structure.
56
56
  * @returns The last element in the array "_nodes" is being returned.
57
57
  */
58
- peekLast(): T | undefined;
58
+ peekLast(): E | undefined;
59
59
  /**
60
60
  * The get function returns the element at the specified index in an array-like data structure.
61
61
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
@@ -63,61 +63,61 @@ export declare class ObjectDeque<T = number> {
63
63
  * @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that
64
64
  * index, `null` is returned.
65
65
  */
66
- get(index: number): NonNullable<T> | null;
66
+ get(index: number): NonNullable<E> | null;
67
67
  /**
68
68
  * The function checks if the size of a data structure is less than or equal to zero.
69
69
  * @returns The method is returning a boolean value indicating whether the size of the object is less than or equal to 0.
70
70
  */
71
71
  isEmpty(): boolean;
72
72
  protected _seNodes(value: {
73
- [p: number]: T;
73
+ [p: number]: E;
74
74
  }): void;
75
75
  protected _setSize(value: number): void;
76
76
  }
77
- export declare class ArrayDeque<T> {
78
- protected _nodes: T[];
77
+ export declare class ArrayDeque<E> {
78
+ protected _nodes: E[];
79
79
  get size(): number;
80
80
  /**
81
81
  * O(n) time complexity of adding at the beginning and the end
82
82
  */
83
83
  /**
84
84
  * The function "addLast" adds a value to the end of an array.
85
- * @param {T} value - The value parameter represents the value that you want to add to the end of the array.
85
+ * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
86
86
  * @returns The return value is the new length of the array after the value has been added.
87
87
  */
88
- addLast(value: T): number;
88
+ addLast(value: E): number;
89
89
  /**
90
90
  * The function "pollLast" returns and removes the last element from an array, or returns null if the array is empty.
91
91
  * @returns The method `pollLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
92
92
  */
93
- pollLast(): T | null;
93
+ pollLast(): E | null;
94
94
  /**
95
95
  * The `pollFirst` function removes and returns the first element from an array, or returns null if the array is empty.
96
96
  * @returns The `pollFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
97
97
  * empty.
98
98
  */
99
- pollFirst(): T | null;
99
+ pollFirst(): E | null;
100
100
  /**
101
101
  * O(n) time complexity of adding at the beginning and the end
102
102
  */
103
103
  /**
104
104
  * The function "addFirst" adds a value to the beginning of an array.
105
- * @param {T} value - The value parameter represents the value that you want to add to the beginning of the array.
105
+ * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
106
106
  * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
107
107
  * `value` at the beginning.
108
108
  */
109
- addFirst(value: T): number;
109
+ addFirst(value: E): number;
110
110
  /**
111
111
  * The `peekFirst` function returns the first element of an array or null if the array is empty.
112
- * @returns The function `peekFirst()` is returning the first element (`T`) of the `_nodes` array. If the array is
112
+ * @returns The function `peekFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
113
113
  * empty, it will return `null`.
114
114
  */
115
- peekFirst(): T | null;
115
+ peekFirst(): E | null;
116
116
  /**
117
117
  * The `peekLast` function returns the last element of an array or null if the array is empty.
118
118
  * @returns The method `peekLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
119
119
  */
120
- peekLast(): T | null;
120
+ peekLast(): E | null;
121
121
  /**
122
122
  * O(1) time complexity of obtaining the value
123
123
  */
@@ -128,34 +128,34 @@ export declare class ArrayDeque<T> {
128
128
  * @returns The method is returning the element at the specified index in the `_nodes` array. If the element exists, it
129
129
  * will be returned. If the element does not exist (i.e., the index is out of bounds), `null` will be returned.
130
130
  */
131
- get(index: number): T | null;
131
+ get(index: number): E | null;
132
132
  /**
133
133
  * The set function assigns a value to a specific index in an array.
134
134
  * @param {number} index - The index parameter is a number that represents the position of the element in the array
135
135
  * that you want to set a new value for.
136
- * @param {T} value - The value parameter represents the new value that you want to set at the specified index in the
136
+ * @param {E} value - The value parameter represents the new value that you want to set at the specified index in the
137
137
  * _nodes array.
138
138
  * @returns The value that is being set at the specified index in the `_nodes` array.
139
139
  */
140
- set(index: number, value: T): T;
140
+ set(index: number, value: E): E;
141
141
  /**
142
142
  * The insert function adds a value at a specified index in an array.
143
143
  * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
144
144
  * array. It is a number that represents the index of the array where the value should be inserted. The index starts
145
145
  * from 0, so the first element of the array has an index of 0, the second element has
146
- * @param {T} value - The value parameter represents the value that you want to insert into the array at the specified
146
+ * @param {E} value - The value parameter represents the value that you want to insert into the array at the specified
147
147
  * index.
148
148
  * @returns The splice method returns an array containing the removed elements, if any. In this case, since no elements
149
149
  * are being removed, an empty array will be returned.
150
150
  */
151
- insert(index: number, value: T): T[];
151
+ insert(index: number, value: E): E[];
152
152
  /**
153
153
  * The remove function removes an element from an array at a specified index.
154
154
  * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
155
155
  * is a number that represents the index of the element to be removed.
156
156
  * @returns The method is returning an array containing the removed element.
157
157
  */
158
- remove(index: number): T[];
158
+ remove(index: number): E[];
159
159
  /**
160
160
  * The function checks if an array called "_nodes" is empty.
161
161
  * @returns The method `isEmpty()` is returning a boolean value. It returns `true` if the length of the `_nodes` array
@@ -49,7 +49,7 @@ export class ObjectDeque {
49
49
  }
50
50
  /**
51
51
  * The "addFirst" function adds a value to the beginning of an array-like data structure.
52
- * @param {T} value - The `value` parameter represents the value that you want to add to the beginning of the data
52
+ * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
53
53
  * structure.
54
54
  */
55
55
  addFirst(value) {
@@ -66,7 +66,7 @@ export class ObjectDeque {
66
66
  }
67
67
  /**
68
68
  * The addLast function adds a value to the end of an array-like data structure.
69
- * @param {T} value - The `value` parameter represents the value that you want to add to the end of the data structure.
69
+ * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
70
70
  */
71
71
  addLast(value) {
72
72
  if (this._size === 0) {
@@ -160,7 +160,7 @@ export class ArrayDeque {
160
160
  */
161
161
  /**
162
162
  * The function "addLast" adds a value to the end of an array.
163
- * @param {T} value - The value parameter represents the value that you want to add to the end of the array.
163
+ * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
164
164
  * @returns The return value is the new length of the array after the value has been added.
165
165
  */
166
166
  addLast(value) {
@@ -188,7 +188,7 @@ export class ArrayDeque {
188
188
  */
189
189
  /**
190
190
  * The function "addFirst" adds a value to the beginning of an array.
191
- * @param {T} value - The value parameter represents the value that you want to add to the beginning of the array.
191
+ * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
192
192
  * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
193
193
  * `value` at the beginning.
194
194
  */
@@ -197,7 +197,7 @@ export class ArrayDeque {
197
197
  }
198
198
  /**
199
199
  * The `peekFirst` function returns the first element of an array or null if the array is empty.
200
- * @returns The function `peekFirst()` is returning the first element (`T`) of the `_nodes` array. If the array is
200
+ * @returns The function `peekFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
201
201
  * empty, it will return `null`.
202
202
  */
203
203
  peekFirst() {
@@ -230,7 +230,7 @@ export class ArrayDeque {
230
230
  * The set function assigns a value to a specific index in an array.
231
231
  * @param {number} index - The index parameter is a number that represents the position of the element in the array
232
232
  * that you want to set a new value for.
233
- * @param {T} value - The value parameter represents the new value that you want to set at the specified index in the
233
+ * @param {E} value - The value parameter represents the new value that you want to set at the specified index in the
234
234
  * _nodes array.
235
235
  * @returns The value that is being set at the specified index in the `_nodes` array.
236
236
  */
@@ -242,7 +242,7 @@ export class ArrayDeque {
242
242
  * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
243
243
  * array. It is a number that represents the index of the array where the value should be inserted. The index starts
244
244
  * from 0, so the first element of the array has an index of 0, the second element has
245
- * @param {T} value - The value parameter represents the value that you want to insert into the array at the specified
245
+ * @param {E} value - The value parameter represents the value that you want to insert into the array at the specified
246
246
  * index.
247
247
  * @returns The splice method returns an array containing the removed elements, if any. In this case, since no elements
248
248
  * are being removed, an empty array will be returned.
@@ -4,34 +4,34 @@
4
4
  * @class
5
5
  */
6
6
  import { SinglyLinkedList } from '../linked-list';
7
- export declare class LinkedListQueue<T = any> extends SinglyLinkedList<T> {
7
+ export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
8
8
  /**
9
9
  * The enqueue function adds a value to the end of an array.
10
- * @param {T} value - The value parameter represents the value that you want to add to the queue.
10
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
11
11
  */
12
- enqueue(value: T): void;
12
+ enqueue(value: E): void;
13
13
  /**
14
14
  * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
15
15
  * @returns The method is returning the element at the front of the queue, or null if the queue is empty.
16
16
  */
17
- dequeue(): T | undefined;
17
+ dequeue(): E | undefined;
18
18
  /**
19
19
  * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
20
20
  * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
21
21
  */
22
- peek(): T | undefined;
22
+ peek(): E | undefined;
23
23
  }
24
- export declare class Queue<T = any> {
24
+ export declare class Queue<E = any> {
25
25
  /**
26
26
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
27
- * @param {T[]} [elements] - The `elements` parameter is an optional array of elements of type `T`. If provided, it
27
+ * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
28
28
  * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
29
29
  * initialized as an empty array.
30
30
  */
31
- constructor(elements?: T[]);
31
+ constructor(elements?: E[]);
32
32
  private _nodes;
33
- get nodes(): T[];
34
- set nodes(value: T[]);
33
+ get nodes(): E[];
34
+ set nodes(value: E[]);
35
35
  private _offset;
36
36
  get offset(): number;
37
37
  set offset(value: number);
@@ -44,46 +44,46 @@ export declare class Queue<T = any> {
44
44
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
45
45
  * @public
46
46
  * @static
47
- * @param {T[]} elements - The "elements" parameter is an array of elements of type T.
47
+ * @param {E[]} elements - The "elements" parameter is an array of elements of type E.
48
48
  * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
49
49
  * array.
50
50
  */
51
- static fromArray<T>(elements: T[]): Queue<T>;
51
+ static fromArray<E>(elements: E[]): Queue<E>;
52
52
  /**
53
53
  * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
54
- * @param {T} element - The `element` parameter represents the element that you want to add to the queue.
55
- * @returns The `add` method is returning a `Queue<T>` object.
54
+ * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
55
+ * @returns The `add` method is returning a `Queue<E>` object.
56
56
  */
57
- push(element: T): Queue<T>;
57
+ push(element: E): Queue<E>;
58
58
  /**
59
59
  * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
60
60
  * necessary to optimize performance.
61
61
  * @returns The function `shift()` returns either the first element in the queue or `null` if the queue is empty.
62
62
  */
63
- shift(): T | undefined;
63
+ shift(): E | undefined;
64
64
  /**
65
65
  * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
66
66
  * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
67
67
  * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
68
68
  */
69
- peek(): T | undefined;
69
+ peek(): E | undefined;
70
70
  /**
71
71
  * The `peekLast` function returns the last element in an array-like data structure, or null if the structure is empty.
72
72
  * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
73
73
  * array is empty, it returns `null`.
74
74
  */
75
- peekLast(): T | undefined;
75
+ peekLast(): E | undefined;
76
76
  /**
77
77
  * The enqueue function adds a value to the end of a queue.
78
- * @param {T} value - The value parameter represents the value that you want to add to the queue.
78
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
79
79
  */
80
- enqueue(value: T): void;
80
+ enqueue(value: E): void;
81
81
  /**
82
82
  * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
83
- * @returns The method is returning a value of type T or null.
83
+ * @returns The method is returning a value of type E or null.
84
84
  */
85
- dequeue(): T | undefined;
86
- getAt(index: number): T | undefined;
85
+ dequeue(): E | undefined;
86
+ getAt(index: number): E | undefined;
87
87
  /**
88
88
  * The function checks if a data structure is empty by comparing its size to zero.
89
89
  * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
@@ -91,9 +91,9 @@ export declare class Queue<T = any> {
91
91
  isEmpty(): boolean;
92
92
  /**
93
93
  * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
94
- * @returns An array of type T is being returned.
94
+ * @returns An array of type E is being returned.
95
95
  */
96
- toArray(): T[];
96
+ toArray(): E[];
97
97
  /**
98
98
  * The clear function resets the nodes array and offset to their initial values.
99
99
  */
@@ -102,6 +102,6 @@ export declare class Queue<T = any> {
102
102
  * The `clone()` function returns a new Queue object with the same elements as the original Queue.
103
103
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
104
104
  */
105
- clone(): Queue<T>;
106
- [Symbol.iterator](): Generator<T, void, unknown>;
105
+ clone(): Queue<E>;
106
+ [Symbol.iterator](): Generator<E, void, unknown>;
107
107
  }
@@ -7,7 +7,7 @@ import { SinglyLinkedList } from '../linked-list';
7
7
  export class LinkedListQueue extends SinglyLinkedList {
8
8
  /**
9
9
  * The enqueue function adds a value to the end of an array.
10
- * @param {T} value - The value parameter represents the value that you want to add to the queue.
10
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
11
11
  */
12
12
  enqueue(value) {
13
13
  this.push(value);
@@ -31,7 +31,7 @@ export class LinkedListQueue extends SinglyLinkedList {
31
31
  export class Queue {
32
32
  /**
33
33
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
34
- * @param {T[]} [elements] - The `elements` parameter is an optional array of elements of type `T`. If provided, it
34
+ * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
35
35
  * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
36
36
  * initialized as an empty array.
37
37
  */
@@ -62,7 +62,7 @@ export class Queue {
62
62
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
63
63
  * @public
64
64
  * @static
65
- * @param {T[]} elements - The "elements" parameter is an array of elements of type T.
65
+ * @param {E[]} elements - The "elements" parameter is an array of elements of type E.
66
66
  * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
67
67
  * array.
68
68
  */
@@ -71,8 +71,8 @@ export class Queue {
71
71
  }
72
72
  /**
73
73
  * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
74
- * @param {T} element - The `element` parameter represents the element that you want to add to the queue.
75
- * @returns The `add` method is returning a `Queue<T>` object.
74
+ * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
75
+ * @returns The `add` method is returning a `Queue<E>` object.
76
76
  */
77
77
  push(element) {
78
78
  this.nodes.push(element);
@@ -114,14 +114,14 @@ export class Queue {
114
114
  }
115
115
  /**
116
116
  * The enqueue function adds a value to the end of a queue.
117
- * @param {T} value - The value parameter represents the value that you want to add to the queue.
117
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
118
118
  */
119
119
  enqueue(value) {
120
120
  this.push(value);
121
121
  }
122
122
  /**
123
123
  * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
124
- * @returns The method is returning a value of type T or null.
124
+ * @returns The method is returning a value of type E or null.
125
125
  */
126
126
  dequeue() {
127
127
  return this.shift();
@@ -138,7 +138,7 @@ export class Queue {
138
138
  }
139
139
  /**
140
140
  * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
141
- * @returns An array of type T is being returned.
141
+ * @returns An array of type E is being returned.
142
142
  */
143
143
  toArray() {
144
144
  return this.nodes.slice(this.offset);
@@ -3,22 +3,22 @@
3
3
  * @copyright Tyler Zeng <zrwusa@gmail.com>
4
4
  * @class
5
5
  */
6
- export declare class Stack<T = number> {
7
- protected _elements: T[];
6
+ export declare class Stack<E = any> {
7
+ protected _elements: E[];
8
8
  /**
9
9
  * The constructor initializes an array of elements, which can be provided as an optional parameter.
10
- * @param {T[]} [elements] - The `elements` parameter is an optional parameter of type `T[]`, which represents an array
11
- * of elements of type `T`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
10
+ * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
11
+ * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
12
12
  * is provided and is an array, it is assigned to the `_elements
13
13
  */
14
- constructor(elements?: T[]);
14
+ constructor(elements?: E[]);
15
15
  /**
16
16
  * The function "fromArray" creates a new Stack object from an array of elements.
17
- * @param {T[]} elements - The `elements` parameter is an array of elements of type `T`.
17
+ * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
18
18
  * @returns {Stack} The method is returning a new instance of the Stack class, initialized with the elements from the input
19
19
  * array.
20
20
  */
21
- static fromArray<T>(elements: T[]): Stack<T>;
21
+ static fromArray<E>(elements: E[]): Stack<E>;
22
22
  /**
23
23
  * The function checks if an array is empty and returns a boolean value.
24
24
  * @returns A boolean value indicating whether the `_elements` array is empty or not.
@@ -33,24 +33,24 @@ export declare class Stack<T = number> {
33
33
  * The `peek` function returns the last element of an array, or null if the array is empty.
34
34
  * @returns The `peek()` function returns the last element of the `_elements` array, or `null` if the array is empty.
35
35
  */
36
- peek(): T | null;
36
+ peek(): E | null;
37
37
  /**
38
38
  * The push function adds an element to the stack and returns the updated stack.
39
- * @param {T} element - The parameter "element" is of type T, which means it can be any data type.
40
- * @returns The `push` method is returning the updated `Stack<T>` object.
39
+ * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
40
+ * @returns The `push` method is returning the updated `Stack<E>` object.
41
41
  */
42
- push(element: T): Stack<T>;
42
+ push(element: E): Stack<E>;
43
43
  /**
44
44
  * The `pop` function removes and returns the last element from an array, or returns null if the array is empty.
45
45
  * @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
46
46
  * array is empty, it returns `null`.
47
47
  */
48
- pop(): T | null;
48
+ pop(): E | null;
49
49
  /**
50
50
  * The toArray function returns a copy of the elements in an array.
51
- * @returns An array of type T.
51
+ * @returns An array of type E.
52
52
  */
53
- toArray(): T[];
53
+ toArray(): E[];
54
54
  /**
55
55
  * The clear function clears the elements array.
56
56
  */
@@ -59,5 +59,5 @@ export declare class Stack<T = number> {
59
59
  * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
60
60
  * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
61
61
  */
62
- clone(): Stack<T>;
62
+ clone(): Stack<E>;
63
63
  }
@@ -6,8 +6,8 @@
6
6
  export class Stack {
7
7
  /**
8
8
  * The constructor initializes an array of elements, which can be provided as an optional parameter.
9
- * @param {T[]} [elements] - The `elements` parameter is an optional parameter of type `T[]`, which represents an array
10
- * of elements of type `T`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
9
+ * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
10
+ * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
11
11
  * is provided and is an array, it is assigned to the `_elements
12
12
  */
13
13
  constructor(elements) {
@@ -15,7 +15,7 @@ export class Stack {
15
15
  }
16
16
  /**
17
17
  * The function "fromArray" creates a new Stack object from an array of elements.
18
- * @param {T[]} elements - The `elements` parameter is an array of elements of type `T`.
18
+ * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
19
19
  * @returns {Stack} The method is returning a new instance of the Stack class, initialized with the elements from the input
20
20
  * array.
21
21
  */
@@ -47,8 +47,8 @@ export class Stack {
47
47
  }
48
48
  /**
49
49
  * The push function adds an element to the stack and returns the updated stack.
50
- * @param {T} element - The parameter "element" is of type T, which means it can be any data type.
51
- * @returns The `push` method is returning the updated `Stack<T>` object.
50
+ * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
51
+ * @returns The `push` method is returning the updated `Stack<E>` object.
52
52
  */
53
53
  push(element) {
54
54
  this._elements.push(element);
@@ -66,7 +66,7 @@ export class Stack {
66
66
  }
67
67
  /**
68
68
  * The toArray function returns a copy of the elements in an array.
69
- * @returns An array of type T.
69
+ * @returns An array of type E.
70
70
  */
71
71
  toArray() {
72
72
  return this._elements.slice();
@@ -1,14 +1,14 @@
1
- export declare class TreeNode<T = any> {
2
- constructor(id: string, value?: T, children?: TreeNode<T>[]);
1
+ export declare class TreeNode<V = any> {
2
+ constructor(id: string, value?: V, children?: TreeNode<V>[]);
3
3
  private _id;
4
4
  get id(): string;
5
5
  set id(value: string);
6
6
  private _value?;
7
- get value(): T | undefined;
8
- set value(value: T | undefined);
7
+ get value(): V | undefined;
8
+ set value(value: V | undefined);
9
9
  private _children?;
10
- get children(): TreeNode<T>[] | undefined;
11
- set children(value: TreeNode<T>[] | undefined);
12
- addChildren(children: TreeNode<T> | TreeNode<T>[]): void;
10
+ get children(): TreeNode<V>[] | undefined;
11
+ set children(value: TreeNode<V>[] | undefined);
12
+ addChildren(children: TreeNode<V> | TreeNode<V>[]): void;
13
13
  getHeight(): number;
14
14
  }
@@ -21,7 +21,6 @@ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'],
21
21
  get visitedId(): BinaryTreeNodeId[];
22
22
  get visitedVal(): Array<N['val']>;
23
23
  get visitedNode(): N[];
24
- get visitedLeftSum(): number[];
25
24
  get root(): N | null;
26
25
  get size(): number;
27
26
  swapLocation(srcNode: N, destNode: N): N;
@@ -4,5 +4,5 @@ import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types';
4
4
  export type IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
5
5
  export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
6
6
  add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined;
7
- remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
7
+ remove(id: BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
8
8
  }
@@ -2,7 +2,7 @@ export type Direction = 'up' | 'right' | 'down' | 'left';
2
2
  export type Turning = {
3
3
  [key in Direction]: Direction;
4
4
  };
5
- export type NavigatorParams<T> = {
5
+ export type NavigatorParams<T = any> = {
6
6
  matrix: T[][];
7
7
  turning: Turning;
8
8
  onMove: (cur: [number, number]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.33.0",
3
+ "version": "1.33.2",
4
4
  "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -15,13 +15,14 @@
15
15
  "build:docs": "typedoc --out docs ./src",
16
16
  "lint": "eslint --fix 'src/**/*.{js,ts}'",
17
17
  "format": "prettier --write 'src/**/*.{js,ts}'",
18
+ "fix": "npm run lint && npm run format",
18
19
  "update:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed queue-typed --save-dev",
19
20
  "test": "jest",
20
21
  "deps:check": "dependency-cruiser src",
21
22
  "changelog": "auto-changelog",
22
23
  "coverage:badge": "istanbul-badges-readme",
23
24
  "package": "npm run lint && npm run test && npm run build && npm run build:docs && npm run changelog",
24
- "deploy": "npm run package && npm publish"
25
+ "deploy": "npm publish"
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",
@@ -41,7 +42,6 @@
41
42
  "in data structure",
42
43
  "DataStructure",
43
44
  "DataStructures",
44
-
45
45
  "binary",
46
46
  "depth",
47
47
  "breadth",
@@ -69,13 +69,11 @@
69
69
  "ts",
70
70
  "javascript",
71
71
  "typscript",
72
-
73
72
  "Node.js",
74
73
  "CommonJS",
75
74
  "ES6",
76
75
  "UMD",
77
76
  "esmodule",
78
-
79
77
  "java.util",
80
78
  "c++ std",
81
79
  "Python collections",