min-heap-typed 1.39.4 → 1.39.5

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.
@@ -11,7 +11,7 @@ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
11
11
  */
12
12
  constructor(key: VertexKey, val?: V);
13
13
  }
14
- export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
14
+ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
15
15
  /**
16
16
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
17
  * value.
@@ -19,21 +19,21 @@ export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
19
19
  * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
20
20
  * graph edge.
21
21
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
22
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
22
+ * @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
23
23
  * with the edge.
24
24
  */
25
- constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: V);
25
+ constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: E);
26
26
  private _vertices;
27
27
  get vertices(): [VertexKey, VertexKey];
28
28
  set vertices(v: [VertexKey, VertexKey]);
29
29
  }
30
- export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
30
+ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVertex<V> = UndirectedVertex<V>, EO extends UndirectedEdge<E> = UndirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
31
31
  /**
32
32
  * The constructor initializes a new Map object to store edges.
33
33
  */
34
34
  constructor();
35
- protected _edges: Map<V, E[]>;
36
- get edges(): Map<V, E[]>;
35
+ protected _edges: Map<VO, EO[]>;
36
+ get edges(): Map<VO, EO[]>;
37
37
  /**
38
38
  * The function creates a new vertex with an optional value and returns it.
39
39
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
@@ -41,9 +41,9 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
41
41
  * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
42
42
  * it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of
43
43
  * the vertex.
44
- * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
44
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
45
45
  */
46
- createVertex(key: VertexKey, val?: V['val']): V;
46
+ createVertex(key: VertexKey, val?: VO['val']): VO;
47
47
  /**
48
48
  * The function creates an undirected edge between two vertices with an optional weight and value.
49
49
  * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
@@ -52,76 +52,76 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
52
52
  * no weight is provided, it defaults to 1.
53
53
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
54
54
  * is used to store additional information or data associated with the edge.
55
- * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
55
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
56
56
  */
57
- createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: E['val']): E;
57
+ createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: EO['val']): EO;
58
58
  /**
59
59
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
60
- * @param {V | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
60
+ * @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
61
61
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
62
- * @param {V | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
62
+ * @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
63
63
  * object), `null`, or `VertexKey` (vertex ID).
64
- * @returns an edge (E) or null.
64
+ * @returns an edge (EO) or null.
65
65
  */
66
- getEdge(v1: V | null | VertexKey, v2: V | null | VertexKey): E | null;
66
+ getEdge(v1: VO | null | VertexKey, v2: VO | null | VertexKey): EO | null;
67
67
  /**
68
68
  * The function removes an edge between two vertices in a graph and returns the removed edge.
69
- * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
70
- * @param {V | VertexKey} v2 - V | VertexKey - This parameter can be either a vertex object (V) or a vertex ID
69
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
70
+ * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
71
71
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
72
- * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
72
+ * @returns the removed edge (EO) if it exists, or null if either of the vertices (VO) does not exist.
73
73
  */
74
- deleteEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
74
+ deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | null;
75
75
  /**
76
76
  * The deleteEdge function removes an edge between two vertices in a graph.
77
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
78
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
77
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
78
+ * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
79
79
  */
80
- deleteEdge(edge: E): E | null;
80
+ deleteEdge(edge: EO): EO | null;
81
81
  /**
82
82
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
83
83
  * vertex.
84
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
84
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
85
85
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
86
86
  * edges connected to that vertex.
87
87
  */
88
- degreeOf(vertexOrKey: VertexKey | V): number;
88
+ degreeOf(vertexOrKey: VertexKey | VO): number;
89
89
  /**
90
90
  * The function returns the edges of a given vertex or vertex ID.
91
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`. A `VertexKey` is a
92
- * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
91
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
92
+ * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
93
93
  * @returns an array of edges.
94
94
  */
95
- edgesOf(vertexOrKey: VertexKey | V): E[];
95
+ edgesOf(vertexOrKey: VertexKey | VO): EO[];
96
96
  /**
97
97
  * The function "edgeSet" returns an array of unique edges from a set of edges.
98
- * @returns The method `edgeSet()` returns an array of type `E[]`.
98
+ * @returns The method `edgeSet()` returns an array of type `EO[]`.
99
99
  */
100
- edgeSet(): E[];
100
+ edgeSet(): EO[];
101
101
  /**
102
102
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
103
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
103
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
104
104
  * (`VertexKey`).
105
- * @returns an array of vertices (V[]).
105
+ * @returns an array of vertices (VO[]).
106
106
  */
107
- getNeighbors(vertexOrKey: V | VertexKey): V[];
107
+ getNeighbors(vertexOrKey: VO | VertexKey): VO[];
108
108
  /**
109
109
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
110
110
  * it returns null.
111
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
112
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
111
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
112
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
113
113
  * graph. If the edge does not exist, it returns `null`.
114
114
  */
115
- getEndsOfEdge(edge: E): [V, V] | null;
115
+ getEndsOfEdge(edge: EO): [VO, VO] | null;
116
116
  /**
117
117
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
118
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
118
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
119
119
  * @returns a boolean value.
120
120
  */
121
- protected _addEdgeOnly(edge: E): boolean;
121
+ protected _addEdgeOnly(edge: EO): boolean;
122
122
  /**
123
123
  * The function sets the edges of a graph.
124
- * @param v - A map where the keys are of type V and the values are arrays of type E.
124
+ * @param v - A map where the keys are of type VO and the values are arrays of type EO.
125
125
  */
126
- protected _setEdges(v: Map<V, E[]>): void;
126
+ protected _setEdges(v: Map<VO, EO[]>): void;
127
127
  }
@@ -31,7 +31,7 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
31
31
  * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
32
32
  * graph edge.
33
33
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
34
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
34
+ * @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
35
35
  * with the edge.
36
36
  */
37
37
  constructor(v1, v2, weight, val) {
@@ -64,7 +64,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
64
64
  * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
65
65
  * it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of
66
66
  * the vertex.
67
- * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
67
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
68
68
  */
69
69
  createVertex(key, val) {
70
70
  return new UndirectedVertex(key, val !== null && val !== void 0 ? val : key);
@@ -77,18 +77,18 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
77
77
  * no weight is provided, it defaults to 1.
78
78
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
79
79
  * is used to store additional information or data associated with the edge.
80
- * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
80
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
81
81
  */
82
82
  createEdge(v1, v2, weight, val) {
83
83
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
84
84
  }
85
85
  /**
86
86
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
87
- * @param {V | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
87
+ * @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
88
88
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
89
- * @param {V | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
89
+ * @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
90
90
  * object), `null`, or `VertexKey` (vertex ID).
91
- * @returns an edge (E) or null.
91
+ * @returns an edge (EO) or null.
92
92
  */
93
93
  getEdge(v1, v2) {
94
94
  var _a;
@@ -104,10 +104,10 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
104
104
  }
105
105
  /**
106
106
  * The function removes an edge between two vertices in a graph and returns the removed edge.
107
- * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
108
- * @param {V | VertexKey} v2 - V | VertexKey - This parameter can be either a vertex object (V) or a vertex ID
107
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
108
+ * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
109
109
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
110
- * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
110
+ * @returns the removed edge (EO) if it exists, or null if either of the vertices (VO) does not exist.
111
111
  */
112
112
  deleteEdgeBetween(v1, v2) {
113
113
  const vertex1 = this._getVertex(v1);
@@ -128,8 +128,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
128
128
  }
129
129
  /**
130
130
  * The deleteEdge function removes an edge between two vertices in a graph.
131
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
132
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
131
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
132
+ * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
133
133
  */
134
134
  deleteEdge(edge) {
135
135
  return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
@@ -137,7 +137,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
137
137
  /**
138
138
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
139
139
  * vertex.
140
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
140
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
141
141
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
142
142
  * edges connected to that vertex.
143
143
  */
@@ -153,8 +153,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
153
153
  }
154
154
  /**
155
155
  * The function returns the edges of a given vertex or vertex ID.
156
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`. A `VertexKey` is a
157
- * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
156
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
157
+ * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
158
158
  * @returns an array of edges.
159
159
  */
160
160
  edgesOf(vertexOrKey) {
@@ -168,7 +168,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
168
168
  }
169
169
  /**
170
170
  * The function "edgeSet" returns an array of unique edges from a set of edges.
171
- * @returns The method `edgeSet()` returns an array of type `E[]`.
171
+ * @returns The method `edgeSet()` returns an array of type `EO[]`.
172
172
  */
173
173
  edgeSet() {
174
174
  const edgeSet = new Set();
@@ -181,9 +181,9 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
181
181
  }
182
182
  /**
183
183
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
184
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
184
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
185
185
  * (`VertexKey`).
186
- * @returns an array of vertices (V[]).
186
+ * @returns an array of vertices (VO[]).
187
187
  */
188
188
  getNeighbors(vertexOrKey) {
189
189
  const neighbors = [];
@@ -202,8 +202,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
202
202
  /**
203
203
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
204
204
  * it returns null.
205
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
206
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
205
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
206
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
207
207
  * graph. If the edge does not exist, it returns `null`.
208
208
  */
209
209
  getEndsOfEdge(edge) {
@@ -221,7 +221,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
221
221
  }
222
222
  /**
223
223
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
224
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
224
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
225
225
  * @returns a boolean value.
226
226
  */
227
227
  _addEdgeOnly(edge) {
@@ -243,7 +243,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
243
243
  }
244
244
  /**
245
245
  * The function sets the edges of a graph.
246
- * @param v - A map where the keys are of type V and the values are arrays of type E.
246
+ * @param v - A map where the keys are of type VO and the values are arrays of type EO.
247
247
  */
248
248
  _setEdges(v) {
249
249
  this._edges = v;
@@ -4,7 +4,7 @@
4
4
  * @class
5
5
  */
6
6
  import { SinglyLinkedList } from '../linked-list';
7
- export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
7
+ export declare class SkipQueue<E = any> extends SinglyLinkedList<E> {
8
8
  /**
9
9
  * The enqueue function adds a value to the end of an array.
10
10
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Queue = exports.LinkedListQueue = void 0;
3
+ exports.Queue = exports.SkipQueue = void 0;
4
4
  /**
5
5
  * @license MIT
6
6
  * @copyright Tyler Zeng <zrwusa@gmail.com>
7
7
  * @class
8
8
  */
9
9
  const linked_list_1 = require("../linked-list");
10
- class LinkedListQueue extends linked_list_1.SinglyLinkedList {
10
+ class SkipQueue extends linked_list_1.SinglyLinkedList {
11
11
  /**
12
12
  * The enqueue function adds a value to the end of an array.
13
13
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -31,7 +31,7 @@ class LinkedListQueue extends linked_list_1.SinglyLinkedList {
31
31
  return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
32
32
  }
33
33
  }
34
- exports.LinkedListQueue = LinkedListQueue;
34
+ exports.SkipQueue = SkipQueue;
35
35
  class Queue {
36
36
  /**
37
37
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
@@ -1,5 +1,5 @@
1
1
  import { VertexKey } from '../types';
2
- export interface IGraph<V, E> {
3
- createVertex(key: VertexKey, val?: V): V;
4
- createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): E;
2
+ export interface IGraph<V, E, VO, EO> {
3
+ createVertex(key: VertexKey, val?: V): VO;
4
+ createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): EO;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "min-heap-typed",
3
- "version": "1.39.4",
3
+ "version": "1.39.5",
4
4
  "description": "Min Heap. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -131,6 +131,6 @@
131
131
  "typescript": "^4.9.5"
132
132
  },
133
133
  "dependencies": {
134
- "data-structure-typed": "^1.39.4"
134
+ "data-structure-typed": "^1.39.5"
135
135
  }
136
136
  }