min-heap-typed 1.50.1 → 1.50.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 (85) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +120 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +72 -47
  4. package/dist/data-structures/binary-tree/avl-tree.js +101 -72
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  8. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  9. package/dist/data-structures/binary-tree/bst.d.ts +92 -79
  10. package/dist/data-structures/binary-tree/bst.js +68 -76
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +127 -57
  12. package/dist/data-structures/binary-tree/rb-tree.js +152 -99
  13. package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
  14. package/dist/data-structures/binary-tree/segment-tree.js +127 -10
  15. package/dist/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  16. package/dist/data-structures/binary-tree/tree-multimap.js +102 -85
  17. package/dist/data-structures/graph/abstract-graph.d.ts +1 -78
  18. package/dist/data-structures/graph/abstract-graph.js +3 -189
  19. package/dist/data-structures/graph/directed-graph.d.ts +73 -0
  20. package/dist/data-structures/graph/directed-graph.js +131 -0
  21. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  22. package/dist/data-structures/graph/map-graph.js +14 -0
  23. package/dist/data-structures/graph/undirected-graph.d.ts +76 -7
  24. package/dist/data-structures/graph/undirected-graph.js +151 -18
  25. package/dist/data-structures/hash/hash-map.d.ts +254 -28
  26. package/dist/data-structures/hash/hash-map.js +347 -78
  27. package/dist/data-structures/heap/heap.d.ts +95 -25
  28. package/dist/data-structures/heap/heap.js +95 -26
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +141 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  32. package/dist/data-structures/linked-list/singly-linked-list.js +164 -115
  33. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  34. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  35. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  36. package/dist/data-structures/matrix/matrix.js +50 -11
  37. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  38. package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
  39. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  40. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
  41. package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
  42. package/dist/data-structures/priority-queue/priority-queue.js +8 -0
  43. package/dist/data-structures/queue/deque.d.ts +139 -35
  44. package/dist/data-structures/queue/deque.js +200 -62
  45. package/dist/data-structures/queue/queue.d.ts +103 -49
  46. package/dist/data-structures/queue/queue.js +111 -49
  47. package/dist/data-structures/stack/stack.d.ts +51 -21
  48. package/dist/data-structures/stack/stack.js +58 -22
  49. package/dist/data-structures/tree/tree.d.ts +57 -3
  50. package/dist/data-structures/tree/tree.js +77 -11
  51. package/dist/data-structures/trie/trie.d.ts +135 -34
  52. package/dist/data-structures/trie/trie.js +153 -33
  53. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  54. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  55. package/dist/types/utils/utils.d.ts +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/iterable-base.ts +184 -19
  58. package/src/data-structures/binary-tree/avl-tree.ts +134 -100
  59. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  60. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  61. package/src/data-structures/binary-tree/bst.ts +127 -136
  62. package/src/data-structures/binary-tree/rb-tree.ts +199 -166
  63. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  64. package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
  65. package/src/data-structures/graph/abstract-graph.ts +4 -211
  66. package/src/data-structures/graph/directed-graph.ts +152 -0
  67. package/src/data-structures/graph/map-graph.ts +15 -0
  68. package/src/data-structures/graph/undirected-graph.ts +171 -19
  69. package/src/data-structures/hash/hash-map.ts +389 -96
  70. package/src/data-structures/heap/heap.ts +97 -26
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
  73. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  74. package/src/data-structures/matrix/matrix.ts +52 -12
  75. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  76. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  77. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  78. package/src/data-structures/queue/deque.ts +225 -70
  79. package/src/data-structures/queue/queue.ts +118 -49
  80. package/src/data-structures/stack/stack.ts +63 -23
  81. package/src/data-structures/tree/tree.ts +89 -15
  82. package/src/data-structures/trie/trie.ts +173 -38
  83. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  84. package/src/types/data-structures/hash/hash-map.ts +4 -3
  85. package/src/types/utils/utils.ts +2 -0
@@ -13,46 +13,70 @@ export declare class SkipListNode<K, V> {
13
13
  constructor(key: K, value: V, level: number);
14
14
  }
15
15
  export declare class SkipList<K, V> {
16
+ /**
17
+ * The constructor function initializes a SkipLinkedList object with optional options and elements.
18
+ * @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
19
+ * is used to initialize the SkipLinkedList with the given key-value pairs. If no elements are
20
+ * provided, the SkipLinkedList will be empty.
21
+ * @param {SkipLinkedListOptions} [options] - The `options` parameter is an optional object that can
22
+ * contain two properties:
23
+ */
16
24
  constructor(elements?: Iterable<[K, V]>, options?: SkipLinkedListOptions);
17
25
  protected _head: SkipListNode<K, V>;
26
+ /**
27
+ * The function returns the head node of a SkipList.
28
+ * @returns The method is returning a SkipListNode object with generic key type K and value type V.
29
+ */
18
30
  get head(): SkipListNode<K, V>;
19
31
  protected _level: number;
32
+ /**
33
+ * The function returns the value of the protected variable _level.
34
+ * @returns The level property of the object.
35
+ */
20
36
  get level(): number;
21
37
  protected _maxLevel: number;
38
+ /**
39
+ * The function returns the maximum level.
40
+ * @returns The value of the variable `_maxLevel` is being returned.
41
+ */
22
42
  get maxLevel(): number;
23
43
  protected _probability: number;
44
+ /**
45
+ * The function returns the probability value.
46
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
47
+ */
24
48
  get probability(): number;
25
49
  /**
26
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
27
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
50
+ * Time Complexity: O(log n)
51
+ * Space Complexity: O(1)
28
52
  */
29
53
  /**
30
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
31
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
54
+ * Time Complexity: O(1)
55
+ * Space Complexity: O(1)
32
56
  *
33
57
  * Get the value of the first element (the smallest element) in the Skip List.
34
58
  * @returns The value of the first element, or undefined if the Skip List is empty.
35
59
  */
36
60
  get first(): V | undefined;
37
61
  /**
38
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
39
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
62
+ * Time Complexity: O(log n)
63
+ * Space Complexity: O(1)
40
64
  */
41
65
  /**
42
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
43
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
66
+ * Time Complexity: O(log n)
67
+ * Space Complexity: O(1)
44
68
  *
45
69
  * Get the value of the last element (the largest element) in the Skip List.
46
70
  * @returns The value of the last element, or undefined if the Skip List is empty.
47
71
  */
48
72
  get last(): V | undefined;
49
73
  /**
50
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
51
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
74
+ * Time Complexity: O(log n)
75
+ * Space Complexity: O(1)
52
76
  */
53
77
  /**
54
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
55
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
78
+ * Time Complexity: O(log n)
79
+ * Space Complexity: O(1)
56
80
  *
57
81
  * The add function adds a new node with a given key and value to a Skip List data structure.
58
82
  * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.
@@ -61,12 +85,12 @@ export declare class SkipList<K, V> {
61
85
  */
62
86
  add(key: K, value: V): void;
63
87
  /**
64
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
65
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
88
+ * Time Complexity: O(log n)
89
+ * Space Complexity: O(1)
66
90
  */
67
91
  /**
68
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
69
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
92
+ * Time Complexity: O(log n)
93
+ * Space Complexity: O(1)
70
94
  *
71
95
  * The function `get` retrieves the value associated with a given key from a skip list data structure.
72
96
  * @param {K} key - The `key` parameter is the key of the element that we want to retrieve from the data structure.
@@ -75,21 +99,23 @@ export declare class SkipList<K, V> {
75
99
  */
76
100
  get(key: K): V | undefined;
77
101
  /**
78
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
79
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
102
+ * Time Complexity: O(log n)
103
+ * Space Complexity: O(1)
80
104
  */
81
105
  /**
82
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
83
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
106
+ * The function checks if a key exists in a data structure.
107
+ * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
108
+ * checked.
109
+ * @returns a boolean value.
84
110
  */
85
111
  has(key: K): boolean;
86
112
  /**
87
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
88
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
113
+ * Time Complexity: O(log n)
114
+ * Space Complexity: O(1)
89
115
  */
90
116
  /**
91
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
92
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
117
+ * Time Complexity: O(log n)
118
+ * Space Complexity: O(1)
93
119
  *
94
120
  * The `delete` function removes a node with a specific key from a Skip List data structure.
95
121
  * @param {K} key - The key parameter represents the key of the node that needs to be removed from the skip list.
@@ -98,12 +124,12 @@ export declare class SkipList<K, V> {
98
124
  */
99
125
  delete(key: K): boolean;
100
126
  /**
101
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
102
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
127
+ * Time Complexity: O(log n)
128
+ * Space Complexity: O(1)
103
129
  */
104
130
  /**
105
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
106
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
131
+ * Time Complexity: O(log n)
132
+ * Space Complexity: O(1)
107
133
  *
108
134
  * Get the value of the first element in the Skip List that is greater than the given key.
109
135
  * @param key - the given key.
@@ -111,12 +137,12 @@ export declare class SkipList<K, V> {
111
137
  */
112
138
  higher(key: K): V | undefined;
113
139
  /**
114
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
115
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
140
+ * Time Complexity: O(log n)
141
+ * Space Complexity: O(1)
116
142
  */
117
143
  /**
118
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
119
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
144
+ * Time Complexity: O(log n)
145
+ * Space Complexity: O(1)
120
146
  *
121
147
  * Get the value of the last element in the Skip List that is less than the given key.
122
148
  * @param key - the given key.
@@ -124,12 +150,13 @@ export declare class SkipList<K, V> {
124
150
  */
125
151
  lower(key: K): V | undefined;
126
152
  /**
127
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
128
- * Space Complexity: O(1) - constant space.
153
+ * Time Complexity: O(maxLevel)
154
+ * Space Complexity: O(1)
155
+ * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
129
156
  */
130
157
  /**
131
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
132
- * Space Complexity: O(1) - constant space.
158
+ * Time Complexity: O(maxLevel)
159
+ * Space Complexity: O(1)
133
160
  *
134
161
  * The function "_randomLevel" generates a random level based on a given probability and maximum level.
135
162
  * @returns the level, which is a number.
@@ -10,6 +10,14 @@ class SkipListNode {
10
10
  }
11
11
  exports.SkipListNode = SkipListNode;
12
12
  class SkipList {
13
+ /**
14
+ * The constructor function initializes a SkipLinkedList object with optional options and elements.
15
+ * @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
16
+ * is used to initialize the SkipLinkedList with the given key-value pairs. If no elements are
17
+ * provided, the SkipLinkedList will be empty.
18
+ * @param {SkipLinkedListOptions} [options] - The `options` parameter is an optional object that can
19
+ * contain two properties:
20
+ */
13
21
  constructor(elements = [], options) {
14
22
  this._head = new SkipListNode(undefined, undefined, this.maxLevel);
15
23
  this._level = 0;
@@ -27,25 +35,41 @@ class SkipList {
27
35
  this.add(key, value);
28
36
  }
29
37
  }
38
+ /**
39
+ * The function returns the head node of a SkipList.
40
+ * @returns The method is returning a SkipListNode object with generic key type K and value type V.
41
+ */
30
42
  get head() {
31
43
  return this._head;
32
44
  }
45
+ /**
46
+ * The function returns the value of the protected variable _level.
47
+ * @returns The level property of the object.
48
+ */
33
49
  get level() {
34
50
  return this._level;
35
51
  }
52
+ /**
53
+ * The function returns the maximum level.
54
+ * @returns The value of the variable `_maxLevel` is being returned.
55
+ */
36
56
  get maxLevel() {
37
57
  return this._maxLevel;
38
58
  }
59
+ /**
60
+ * The function returns the probability value.
61
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
62
+ */
39
63
  get probability() {
40
64
  return this._probability;
41
65
  }
42
66
  /**
43
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
44
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
67
+ * Time Complexity: O(log n)
68
+ * Space Complexity: O(1)
45
69
  */
46
70
  /**
47
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
48
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
71
+ * Time Complexity: O(1)
72
+ * Space Complexity: O(1)
49
73
  *
50
74
  * Get the value of the first element (the smallest element) in the Skip List.
51
75
  * @returns The value of the first element, or undefined if the Skip List is empty.
@@ -55,12 +79,12 @@ class SkipList {
55
79
  return firstNode ? firstNode.value : undefined;
56
80
  }
57
81
  /**
58
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
59
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
82
+ * Time Complexity: O(log n)
83
+ * Space Complexity: O(1)
60
84
  */
61
85
  /**
62
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
63
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
86
+ * Time Complexity: O(log n)
87
+ * Space Complexity: O(1)
64
88
  *
65
89
  * Get the value of the last element (the largest element) in the Skip List.
66
90
  * @returns The value of the last element, or undefined if the Skip List is empty.
@@ -75,12 +99,12 @@ class SkipList {
75
99
  return current.value;
76
100
  }
77
101
  /**
78
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
79
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
102
+ * Time Complexity: O(log n)
103
+ * Space Complexity: O(1)
80
104
  */
81
105
  /**
82
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
83
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
106
+ * Time Complexity: O(log n)
107
+ * Space Complexity: O(1)
84
108
  *
85
109
  * The add function adds a new node with a given key and value to a Skip List data structure.
86
110
  * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.
@@ -106,12 +130,12 @@ class SkipList {
106
130
  }
107
131
  }
108
132
  /**
109
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
110
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
133
+ * Time Complexity: O(log n)
134
+ * Space Complexity: O(1)
111
135
  */
112
136
  /**
113
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
114
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
137
+ * Time Complexity: O(log n)
138
+ * Space Complexity: O(1)
115
139
  *
116
140
  * The function `get` retrieves the value associated with a given key from a skip list data structure.
117
141
  * @param {K} key - The `key` parameter is the key of the element that we want to retrieve from the data structure.
@@ -132,23 +156,25 @@ class SkipList {
132
156
  return undefined;
133
157
  }
134
158
  /**
135
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
136
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
159
+ * Time Complexity: O(log n)
160
+ * Space Complexity: O(1)
137
161
  */
138
162
  /**
139
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
140
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
163
+ * The function checks if a key exists in a data structure.
164
+ * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
165
+ * checked.
166
+ * @returns a boolean value.
141
167
  */
142
168
  has(key) {
143
169
  return this.get(key) !== undefined;
144
170
  }
145
171
  /**
146
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
147
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
172
+ * Time Complexity: O(log n)
173
+ * Space Complexity: O(1)
148
174
  */
149
175
  /**
150
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
151
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
176
+ * Time Complexity: O(log n)
177
+ * Space Complexity: O(1)
152
178
  *
153
179
  * The `delete` function removes a node with a specific key from a Skip List data structure.
154
180
  * @param {K} key - The key parameter represents the key of the node that needs to be removed from the skip list.
@@ -180,12 +206,12 @@ class SkipList {
180
206
  return false;
181
207
  }
182
208
  /**
183
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
184
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
209
+ * Time Complexity: O(log n)
210
+ * Space Complexity: O(1)
185
211
  */
186
212
  /**
187
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
188
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
213
+ * Time Complexity: O(log n)
214
+ * Space Complexity: O(1)
189
215
  *
190
216
  * Get the value of the first element in the Skip List that is greater than the given key.
191
217
  * @param key - the given key.
@@ -202,12 +228,12 @@ class SkipList {
202
228
  return nextNode ? nextNode.value : undefined;
203
229
  }
204
230
  /**
205
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
206
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
231
+ * Time Complexity: O(log n)
232
+ * Space Complexity: O(1)
207
233
  */
208
234
  /**
209
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
210
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
235
+ * Time Complexity: O(log n)
236
+ * Space Complexity: O(1)
211
237
  *
212
238
  * Get the value of the last element in the Skip List that is less than the given key.
213
239
  * @param key - the given key.
@@ -227,12 +253,13 @@ class SkipList {
227
253
  return lastLess ? lastLess.value : undefined;
228
254
  }
229
255
  /**
230
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
231
- * Space Complexity: O(1) - constant space.
256
+ * Time Complexity: O(maxLevel)
257
+ * Space Complexity: O(1)
258
+ * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
232
259
  */
233
260
  /**
234
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
235
- * Space Complexity: O(1) - constant space.
261
+ * Time Complexity: O(maxLevel)
262
+ * Space Complexity: O(1)
236
263
  *
237
264
  * The function "_randomLevel" generates a random level based on a given probability and maximum level.
238
265
  * @returns the level, which is a number.
@@ -16,13 +16,37 @@ export declare class Matrix {
16
16
  */
17
17
  constructor(data: number[][], options?: MatrixOptions);
18
18
  protected _rows: number;
19
+ /**
20
+ * The function returns the number of rows.
21
+ * @returns The number of rows.
22
+ */
19
23
  get rows(): number;
20
24
  protected _cols: number;
25
+ /**
26
+ * The function returns the value of the protected variable _cols.
27
+ * @returns The number of columns.
28
+ */
21
29
  get cols(): number;
22
30
  protected _data: number[][];
31
+ /**
32
+ * The function returns a two-dimensional array of numbers.
33
+ * @returns The data property, which is a two-dimensional array of numbers.
34
+ */
23
35
  get data(): number[][];
36
+ /**
37
+ * The above function returns the value of the _addFn property.
38
+ * @returns The value of the property `_addFn` is being returned.
39
+ */
24
40
  get addFn(): (a: number | undefined, b: number) => number | undefined;
41
+ /**
42
+ * The function returns the value of the _subtractFn property.
43
+ * @returns The `_subtractFn` property is being returned.
44
+ */
25
45
  get subtractFn(): (a: number, b: number) => number;
46
+ /**
47
+ * The function returns the value of the _multiplyFn property.
48
+ * @returns The `_multiplyFn` property is being returned.
49
+ */
26
50
  get multiplyFn(): (a: number, b: number) => number;
27
51
  /**
28
52
  * The `get` function returns the value at the specified row and column index if it is a valid index.
@@ -93,9 +117,6 @@ export declare class Matrix {
93
117
  * @returns a new Matrix object.
94
118
  */
95
119
  dot(matrix: Matrix): Matrix | undefined;
96
- protected _addFn(a: number | undefined, b: number): number | undefined;
97
- protected _subtractFn(a: number, b: number): number;
98
- protected _multiplyFn(a: number, b: number): number;
99
120
  /**
100
121
  * The function checks if a given row and column index is valid within a specified range.
101
122
  * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
@@ -104,7 +125,17 @@ export declare class Matrix {
104
125
  * or grid. It is used to check if the given column index is valid within the bounds of the grid.
105
126
  * @returns A boolean value is being returned.
106
127
  */
107
- protected isValidIndex(row: number, col: number): boolean;
128
+ isValidIndex(row: number, col: number): boolean;
129
+ /**
130
+ * The `clone` function returns a new instance of the Matrix class with the same data and properties
131
+ * as the original instance.
132
+ * @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
133
+ * and properties as the current instance.
134
+ */
135
+ clone(): Matrix;
136
+ protected _addFn(a: number | undefined, b: number): number | undefined;
137
+ protected _subtractFn(a: number, b: number): number;
138
+ protected _multiplyFn(a: number, b: number): number;
108
139
  /**
109
140
  * The function `_swapRows` swaps the positions of two rows in an array.
110
141
  * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
@@ -44,21 +44,45 @@ class Matrix {
44
44
  }
45
45
  }
46
46
  }
47
+ /**
48
+ * The function returns the number of rows.
49
+ * @returns The number of rows.
50
+ */
47
51
  get rows() {
48
52
  return this._rows;
49
53
  }
54
+ /**
55
+ * The function returns the value of the protected variable _cols.
56
+ * @returns The number of columns.
57
+ */
50
58
  get cols() {
51
59
  return this._cols;
52
60
  }
61
+ /**
62
+ * The function returns a two-dimensional array of numbers.
63
+ * @returns The data property, which is a two-dimensional array of numbers.
64
+ */
53
65
  get data() {
54
66
  return this._data;
55
67
  }
68
+ /**
69
+ * The above function returns the value of the _addFn property.
70
+ * @returns The value of the property `_addFn` is being returned.
71
+ */
56
72
  get addFn() {
57
73
  return this._addFn;
58
74
  }
75
+ /**
76
+ * The function returns the value of the _subtractFn property.
77
+ * @returns The `_subtractFn` property is being returned.
78
+ */
59
79
  get subtractFn() {
60
80
  return this._subtractFn;
61
81
  }
82
+ /**
83
+ * The function returns the value of the _multiplyFn property.
84
+ * @returns The `_multiplyFn` property is being returned.
85
+ */
62
86
  get multiplyFn() {
63
87
  return this._multiplyFn;
64
88
  }
@@ -332,17 +356,6 @@ class Matrix {
332
356
  multiplyFn: this.multiplyFn
333
357
  });
334
358
  }
335
- _addFn(a, b) {
336
- if (a === undefined)
337
- return b;
338
- return a + b;
339
- }
340
- _subtractFn(a, b) {
341
- return a - b;
342
- }
343
- _multiplyFn(a, b) {
344
- return a * b;
345
- }
346
359
  /**
347
360
  * The function checks if a given row and column index is valid within a specified range.
348
361
  * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
@@ -354,6 +367,32 @@ class Matrix {
354
367
  isValidIndex(row, col) {
355
368
  return row >= 0 && row < this.rows && col >= 0 && col < this.cols;
356
369
  }
370
+ /**
371
+ * The `clone` function returns a new instance of the Matrix class with the same data and properties
372
+ * as the original instance.
373
+ * @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
374
+ * and properties as the current instance.
375
+ */
376
+ clone() {
377
+ return new Matrix(this.data, {
378
+ rows: this.rows,
379
+ cols: this.cols,
380
+ addFn: this.addFn,
381
+ subtractFn: this.subtractFn,
382
+ multiplyFn: this.multiplyFn
383
+ });
384
+ }
385
+ _addFn(a, b) {
386
+ if (a === undefined)
387
+ return b;
388
+ return a + b;
389
+ }
390
+ _subtractFn(a, b) {
391
+ return a - b;
392
+ }
393
+ _multiplyFn(a, b) {
394
+ return a * b;
395
+ }
357
396
  /**
358
397
  * The function `_swapRows` swaps the positions of two rows in an array.
359
398
  * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
@@ -8,5 +8,15 @@
8
8
  import type { PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
  export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
11
+ /**
12
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
13
+ * comparator function.
14
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
15
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
16
+ * provided.
17
+ * @param options - The `options` parameter is an object that contains additional configuration
18
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
19
+ * function used to compare elements in the priority queue.
20
+ */
11
21
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
12
22
  }
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MaxPriorityQueue = void 0;
4
4
  const priority_queue_1 = require("./priority-queue");
5
5
  class MaxPriorityQueue extends priority_queue_1.PriorityQueue {
6
+ /**
7
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
8
+ * comparator function.
9
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
10
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
11
+ * provided.
12
+ * @param options - The `options` parameter is an object that contains additional configuration
13
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
14
+ * function used to compare elements in the priority queue.
15
+ */
6
16
  constructor(elements = [], options = {
7
17
  comparator: (a, b) => {
8
18
  if (!(typeof a === 'number' && typeof b === 'number')) {
@@ -8,5 +8,16 @@
8
8
  import type { PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
  export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
11
+ /**
12
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
13
+ * comparator function.
14
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
15
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
16
+ * provided.
17
+ * @param options - The `options` parameter is an object that contains additional configuration
18
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
19
+ * function used to compare elements in the priority queue. The `comparator` function takes two
20
+ * parameters `a` and `b`,
21
+ */
11
22
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
12
23
  }
@@ -3,6 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MinPriorityQueue = void 0;
4
4
  const priority_queue_1 = require("./priority-queue");
5
5
  class MinPriorityQueue extends priority_queue_1.PriorityQueue {
6
+ /**
7
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
8
+ * comparator function.
9
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
10
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
11
+ * provided.
12
+ * @param options - The `options` parameter is an object that contains additional configuration
13
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
14
+ * function used to compare elements in the priority queue. The `comparator` function takes two
15
+ * parameters `a` and `b`,
16
+ */
6
17
  constructor(elements = [], options = {
7
18
  comparator: (a, b) => {
8
19
  if (!(typeof a === 'number' && typeof b === 'number')) {
@@ -16,5 +16,13 @@ import { Heap } from '../heap';
16
16
  * 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
17
17
  */
18
18
  export declare class PriorityQueue<E = any> extends Heap<E> {
19
+ /**
20
+ * The constructor initializes a priority queue with optional elements and options.
21
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
22
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
23
+ * priority queue will be initialized as empty.
24
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
25
+ * behavior of the priority queue. It can contain the following properties:
26
+ */
19
27
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
20
28
  }
@@ -11,6 +11,14 @@ const heap_1 = require("../heap");
11
11
  * 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
12
12
  */
13
13
  class PriorityQueue extends heap_1.Heap {
14
+ /**
15
+ * The constructor initializes a priority queue with optional elements and options.
16
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
17
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
18
+ * priority queue will be initialized as empty.
19
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
20
+ * behavior of the priority queue. It can contain the following properties:
21
+ */
14
22
  constructor(elements = [], options) {
15
23
  super(elements, options);
16
24
  }