data-structure-typed 1.19.6 → 1.19.7

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.
@@ -25,8 +25,7 @@ export declare class HeapItem<T = number> {
25
25
  }
26
26
  export declare abstract class Heap<T = number> {
27
27
  /**
28
- * The function is a constructor for a class that initializes a priority callback function based on the
29
- * options provided.
28
+ * The constructor function initializes a priority queue with an optional priority extractor function.
30
29
  * @param [options] - An optional object that contains configuration options for the Heap.
31
30
  */
32
31
  protected constructor(options?: HeapOptions<T>);
@@ -65,8 +64,8 @@ export declare abstract class Heap<T = number> {
65
64
  poll(isItem: false): T | undefined;
66
65
  poll(isItem: true): HeapItem<T> | null;
67
66
  /**
68
- * The function checks if a given node or value exists in the priority queue.
69
- * @param {T | HeapItem<T>} node - The parameter `node` can be of type `T` or `HeapItem<T>`.
67
+ * The `has` function checks if a given node or value exists in the priority queue.
68
+ * @param {T | HeapItem<T>} node - The `node` parameter can be of type `T` or `HeapItem<T>`.
70
69
  * @returns a boolean value.
71
70
  */
72
71
  has(node: T | HeapItem<T>): boolean;
@@ -29,8 +29,7 @@ class HeapItem {
29
29
  exports.HeapItem = HeapItem;
30
30
  class Heap {
31
31
  /**
32
- * The function is a constructor for a class that initializes a priority callback function based on the
33
- * options provided.
32
+ * The constructor function initializes a priority queue with an optional priority extractor function.
34
33
  * @param [options] - An optional object that contains configuration options for the Heap.
35
34
  */
36
35
  constructor(options) {
@@ -66,8 +65,14 @@ class Heap {
66
65
  return this._pq.size < 1;
67
66
  }
68
67
  /**
69
- * The `peek` function returns the top item in the priority queue without removing it.
70
- * @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an val with the highest priority in the queue
68
+ * The `peek` function returns the top item or value in a priority queue, depending on the value of the `isItem`
69
+ * parameter.
70
+ * @param {boolean} [isItem] - The `isItem` parameter is an optional boolean parameter that determines whether the
71
+ * method should return the entire `HeapItem` object or just the value of the item. If `isItem` is set to `true`, the
72
+ * method will return the `HeapItem` object. If `isItem`
73
+ * @returns The `peek` method returns either a `HeapItem<T>` object, `null`, `T`, or `undefined`. The specific return
74
+ * type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a `HeapItem<T>`
75
+ * object or `null` if the heap is empty. If `isItem` is `false`
71
76
  */
72
77
  peek(isItem) {
73
78
  isItem = isItem !== null && isItem !== void 0 ? isItem : false;
@@ -75,8 +80,14 @@ class Heap {
75
80
  return isItem ? peeked : peeked === null || peeked === void 0 ? void 0 : peeked.val;
76
81
  }
77
82
  /**
78
- * The `peekLast` function returns the last item in the heap.
79
- * @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an val with the lowest priority in the queue
83
+ * The `peekLast` function returns the last item in the heap, either as a `HeapItem` object or just the value depending
84
+ * on the `isItem` parameter.
85
+ * @param {boolean} [isItem] - A boolean parameter that indicates whether the method should return the HeapItem object
86
+ * or just the value of the last item in the heap. If isItem is true, the method will return the HeapItem object. If
87
+ * isItem is false or not provided, the method will return the value of the last item
88
+ * @returns The method `peekLast` returns either a `HeapItem<T>` object, `null`, `T`, or `undefined`. The specific
89
+ * return type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a
90
+ * `HeapItem<T>` object or `null` if there are no items in the heap. If `isItem`
80
91
  */
81
92
  peekLast(isItem) {
82
93
  isItem = isItem !== null && isItem !== void 0 ? isItem : false;
@@ -99,8 +110,13 @@ class Heap {
99
110
  return this;
100
111
  }
101
112
  /**
102
- * The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an val with the highest priority in the queue
103
- * @returns either a HeapItem<T> object or null.
113
+ * The `poll` function returns the top item from a priority queue, either as a HeapItem object or its value, depending
114
+ * on the value of the `isItem` parameter.
115
+ * @param {boolean} [isItem] - The `isItem` parameter is a boolean flag that indicates whether the returned value
116
+ * should be a `HeapItem<T>` object or just the value `T` itself. If `isItem` is `true`, the method will return the
117
+ * `HeapItem<T>` object, otherwise it will return just
118
+ * @returns The function `poll` returns either a `HeapItem<T>` object, `null`, or `T` (the value of the `val` property
119
+ * of the `HeapItem<T>` object).
104
120
  */
105
121
  poll(isItem) {
106
122
  isItem = isItem !== null && isItem !== void 0 ? isItem : false;
@@ -111,8 +127,8 @@ class Heap {
111
127
  return isItem ? top : top.val;
112
128
  }
113
129
  /**
114
- * The function checks if a given node or value exists in the priority queue.
115
- * @param {T | HeapItem<T>} node - The parameter `node` can be of type `T` or `HeapItem<T>`.
130
+ * The `has` function checks if a given node or value exists in the priority queue.
131
+ * @param {T | HeapItem<T>} node - The `node` parameter can be of type `T` or `HeapItem<T>`.
116
132
  * @returns a boolean value.
117
133
  */
118
134
  has(node) {
@@ -126,8 +142,13 @@ class Heap {
126
142
  }
127
143
  }
128
144
  /**
129
- * The `toArray` function returns an array of `HeapItem<T>` objects.
130
- * @returns An array of HeapItem<T> objects.Returns a sorted list of vals
145
+ * The `toArray` function returns an array of either HeapItem objects or their values, depending on the value of the
146
+ * `isItem` parameter.
147
+ * @param {boolean} [isItem] - isItem is an optional boolean parameter that determines whether the returned array
148
+ * should contain the HeapItem objects or just the values of the HeapItem objects. If isItem is true, the array will
149
+ * contain the HeapItem objects. If isItem is false or not provided, the array will contain only the values
150
+ * @returns The method `toArray` returns an array of `HeapItem<T>` objects, or an array of `T` values if the `isItem`
151
+ * parameter is set to `false`.
131
152
  */
132
153
  toArray(isItem) {
133
154
  isItem = isItem !== null && isItem !== void 0 ? isItem : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.19.6",
3
+ "version": "1.19.7",
4
4
  "description": "Javascript & TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -170,7 +170,6 @@ export abstract class AbstractGraph<V extends AbstractVertex<any>, E extends Abs
170
170
  addVertex(idOrVertex: VertexId | V, val?: V['val']): boolean {
171
171
  if (idOrVertex instanceof AbstractVertex) {
172
172
  return this._addVertexOnly(idOrVertex);
173
-
174
173
  } else {
175
174
  const newVertex = this.createVertex(idOrVertex, val);
176
175
  return this._addVertexOnly(newVertex);
@@ -44,9 +44,9 @@ export class HeapItem<T = number> {
44
44
  }
45
45
 
46
46
  export abstract class Heap<T = number> {
47
+
47
48
  /**
48
- * The function is a constructor for a class that initializes a priority callback function based on the
49
- * options provided.
49
+ * The constructor function initializes a priority queue with an optional priority extractor function.
50
50
  * @param [options] - An optional object that contains configuration options for the Heap.
51
51
  */
52
52
  protected constructor(options?: HeapOptions<T>) {
@@ -91,9 +91,16 @@ export abstract class Heap<T = number> {
91
91
  peek(isItem?: undefined): T | undefined;
92
92
  peek(isItem: false): T | undefined;
93
93
  peek(isItem: true): HeapItem<T> | null;
94
+
94
95
  /**
95
- * The `peek` function returns the top item in the priority queue without removing it.
96
- * @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an val with the highest priority in the queue
96
+ * The `peek` function returns the top item or value in a priority queue, depending on the value of the `isItem`
97
+ * parameter.
98
+ * @param {boolean} [isItem] - The `isItem` parameter is an optional boolean parameter that determines whether the
99
+ * method should return the entire `HeapItem` object or just the value of the item. If `isItem` is set to `true`, the
100
+ * method will return the `HeapItem` object. If `isItem`
101
+ * @returns The `peek` method returns either a `HeapItem<T>` object, `null`, `T`, or `undefined`. The specific return
102
+ * type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a `HeapItem<T>`
103
+ * object or `null` if the heap is empty. If `isItem` is `false`
97
104
  */
98
105
  peek(isItem?: boolean): HeapItem<T> | null | T | undefined {
99
106
  isItem = isItem ?? false;
@@ -104,9 +111,16 @@ export abstract class Heap<T = number> {
104
111
  peekLast(isItem?: undefined): T | undefined;
105
112
  peekLast(isItem: false): T | undefined;
106
113
  peekLast(isItem: true): HeapItem<T> | null;
114
+
107
115
  /**
108
- * The `peekLast` function returns the last item in the heap.
109
- * @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an val with the lowest priority in the queue
116
+ * The `peekLast` function returns the last item in the heap, either as a `HeapItem` object or just the value depending
117
+ * on the `isItem` parameter.
118
+ * @param {boolean} [isItem] - A boolean parameter that indicates whether the method should return the HeapItem object
119
+ * or just the value of the last item in the heap. If isItem is true, the method will return the HeapItem object. If
120
+ * isItem is false or not provided, the method will return the value of the last item
121
+ * @returns The method `peekLast` returns either a `HeapItem<T>` object, `null`, `T`, or `undefined`. The specific
122
+ * return type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a
123
+ * `HeapItem<T>` object or `null` if there are no items in the heap. If `isItem`
110
124
  */
111
125
  peekLast(isItem?: boolean): HeapItem<T> | null | T | undefined {
112
126
  isItem = isItem ?? false;
@@ -133,9 +147,15 @@ export abstract class Heap<T = number> {
133
147
  poll(isItem?: undefined): T | undefined;
134
148
  poll(isItem: false): T | undefined;
135
149
  poll(isItem: true): HeapItem<T> | null;
150
+
136
151
  /**
137
- * The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an val with the highest priority in the queue
138
- * @returns either a HeapItem<T> object or null.
152
+ * The `poll` function returns the top item from a priority queue, either as a HeapItem object or its value, depending
153
+ * on the value of the `isItem` parameter.
154
+ * @param {boolean} [isItem] - The `isItem` parameter is a boolean flag that indicates whether the returned value
155
+ * should be a `HeapItem<T>` object or just the value `T` itself. If `isItem` is `true`, the method will return the
156
+ * `HeapItem<T>` object, otherwise it will return just
157
+ * @returns The function `poll` returns either a `HeapItem<T>` object, `null`, or `T` (the value of the `val` property
158
+ * of the `HeapItem<T>` object).
139
159
  */
140
160
  poll(isItem?: boolean): HeapItem<T> | null | T | undefined {
141
161
  isItem = isItem ?? false;
@@ -147,8 +167,8 @@ export abstract class Heap<T = number> {
147
167
  }
148
168
 
149
169
  /**
150
- * The function checks if a given node or value exists in the priority queue.
151
- * @param {T | HeapItem<T>} node - The parameter `node` can be of type `T` or `HeapItem<T>`.
170
+ * The `has` function checks if a given node or value exists in the priority queue.
171
+ * @param {T | HeapItem<T>} node - The `node` parameter can be of type `T` or `HeapItem<T>`.
152
172
  * @returns a boolean value.
153
173
  */
154
174
  has(node: T | HeapItem<T>): boolean {
@@ -164,9 +184,15 @@ export abstract class Heap<T = number> {
164
184
  toArray(isItem?: undefined): (T | undefined)[];
165
185
  toArray(isItem: false): (T | undefined)[];
166
186
  toArray(isItem: true): (HeapItem<T> | null)[];
187
+
167
188
  /**
168
- * The `toArray` function returns an array of `HeapItem<T>` objects.
169
- * @returns An array of HeapItem<T> objects.Returns a sorted list of vals
189
+ * The `toArray` function returns an array of either HeapItem objects or their values, depending on the value of the
190
+ * `isItem` parameter.
191
+ * @param {boolean} [isItem] - isItem is an optional boolean parameter that determines whether the returned array
192
+ * should contain the HeapItem objects or just the values of the HeapItem objects. If isItem is true, the array will
193
+ * contain the HeapItem objects. If isItem is false or not provided, the array will contain only the values
194
+ * @returns The method `toArray` returns an array of `HeapItem<T>` objects, or an array of `T` values if the `isItem`
195
+ * parameter is set to `false`.
170
196
  */
171
197
  toArray(isItem?: boolean): (HeapItem<T> | null | T | undefined)[] {
172
198
  isItem = isItem ?? false;