data-structure-typed 1.35.0 → 1.40.0-rc

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 (173) hide show
  1. package/.github/workflows/ci.yml +3 -0
  2. package/CHANGELOG.md +3 -1
  3. package/CONTRIBUTING.md +18 -0
  4. package/dist/data-structures/binary-tree/aa-tree.d.ts +2 -0
  5. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +527 -0
  6. package/dist/data-structures/binary-tree/abstract-binary-tree.js +323 -0
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  8. package/dist/data-structures/binary-tree/avl-tree.d.ts +94 -0
  9. package/dist/data-structures/binary-tree/avl-tree.js +90 -3
  10. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/b-tree.d.ts +2 -0
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +46 -0
  13. package/dist/data-structures/binary-tree/binary-indexed-tree.js +36 -0
  14. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  15. package/dist/data-structures/binary-tree/binary-tree.d.ts +31 -0
  16. package/dist/data-structures/binary-tree/binary-tree.js +21 -0
  17. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  18. package/dist/data-structures/binary-tree/bst.d.ts +133 -0
  19. package/dist/data-structures/binary-tree/bst.js +114 -0
  20. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  21. package/dist/data-structures/binary-tree/index.d.ts +12 -0
  22. package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
  23. package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
  24. package/dist/data-structures/binary-tree/segment-tree.js +45 -0
  25. package/dist/data-structures/binary-tree/segment-tree.js.map +1 -1
  26. package/dist/data-structures/binary-tree/splay-tree.d.ts +2 -0
  27. package/dist/data-structures/binary-tree/tree-multiset.d.ts +209 -0
  28. package/dist/data-structures/binary-tree/tree-multiset.js +178 -0
  29. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  30. package/dist/data-structures/binary-tree/two-three-tree.d.ts +2 -0
  31. package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
  32. package/dist/data-structures/graph/abstract-graph.js +269 -4
  33. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  34. package/dist/data-structures/graph/directed-graph.d.ts +200 -0
  35. package/dist/data-structures/graph/directed-graph.js +167 -0
  36. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  37. package/dist/data-structures/graph/index.d.ts +4 -0
  38. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  39. package/dist/data-structures/graph/map-graph.js +54 -0
  40. package/dist/data-structures/graph/map-graph.js.map +1 -1
  41. package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
  42. package/dist/data-structures/graph/undirected-graph.js +105 -0
  43. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  44. package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
  45. package/dist/data-structures/hash/coordinate-map.js +35 -0
  46. package/dist/data-structures/hash/coordinate-map.js.map +1 -1
  47. package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
  48. package/dist/data-structures/hash/coordinate-set.js +28 -0
  49. package/dist/data-structures/hash/coordinate-set.js.map +1 -1
  50. package/dist/data-structures/hash/hash-map.d.ts +56 -0
  51. package/dist/data-structures/hash/hash-map.js +29 -1
  52. package/dist/data-structures/hash/hash-map.js.map +1 -1
  53. package/dist/data-structures/hash/hash-table.d.ts +106 -0
  54. package/dist/data-structures/hash/hash-table.js +88 -6
  55. package/dist/data-structures/hash/hash-table.js.map +1 -1
  56. package/dist/data-structures/hash/index.d.ts +7 -0
  57. package/dist/data-structures/hash/pair.d.ts +2 -0
  58. package/dist/data-structures/hash/tree-map.d.ts +2 -0
  59. package/dist/data-structures/hash/tree-set.d.ts +2 -0
  60. package/dist/data-structures/heap/heap.d.ts +83 -0
  61. package/dist/data-structures/heap/heap.js +62 -0
  62. package/dist/data-structures/heap/heap.js.map +1 -1
  63. package/dist/data-structures/heap/index.d.ts +3 -0
  64. package/dist/data-structures/heap/max-heap.d.ts +23 -0
  65. package/dist/data-structures/heap/max-heap.js +16 -0
  66. package/dist/data-structures/heap/max-heap.js.map +1 -1
  67. package/dist/data-structures/heap/min-heap.d.ts +24 -0
  68. package/dist/data-structures/heap/min-heap.js +17 -0
  69. package/dist/data-structures/heap/min-heap.js.map +1 -1
  70. package/dist/data-structures/index.d.ts +11 -0
  71. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
  72. package/dist/data-structures/linked-list/doubly-linked-list.js +202 -0
  73. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  74. package/dist/data-structures/linked-list/index.d.ts +3 -0
  75. package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
  76. package/dist/data-structures/linked-list/singly-linked-list.js +135 -0
  77. package/dist/data-structures/linked-list/singly-linked-list.js.map +1 -1
  78. package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
  79. package/dist/data-structures/linked-list/skip-linked-list.js +36 -0
  80. package/dist/data-structures/linked-list/skip-linked-list.js.map +1 -1
  81. package/dist/data-structures/matrix/index.d.ts +4 -0
  82. package/dist/data-structures/matrix/matrix.d.ts +21 -0
  83. package/dist/data-structures/matrix/matrix.js +15 -0
  84. package/dist/data-structures/matrix/matrix.js.map +1 -1
  85. package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
  86. package/dist/data-structures/matrix/matrix2d.js +91 -2
  87. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  88. package/dist/data-structures/matrix/navigator.d.ts +52 -0
  89. package/dist/data-structures/matrix/navigator.js +28 -0
  90. package/dist/data-structures/matrix/navigator.js.map +1 -1
  91. package/dist/data-structures/matrix/vector2d.d.ts +201 -0
  92. package/dist/data-structures/matrix/vector2d.js +188 -1
  93. package/dist/data-structures/matrix/vector2d.js.map +1 -1
  94. package/dist/data-structures/priority-queue/index.d.ts +3 -0
  95. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +15 -0
  96. package/dist/data-structures/priority-queue/max-priority-queue.js +18 -0
  97. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  98. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +15 -0
  99. package/dist/data-structures/priority-queue/min-priority-queue.js +19 -0
  100. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  101. package/dist/data-structures/priority-queue/priority-queue.d.ts +180 -0
  102. package/dist/data-structures/priority-queue/priority-queue.js +141 -0
  103. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  104. package/dist/data-structures/queue/deque.d.ts +165 -0
  105. package/dist/data-structures/queue/deque.js +124 -0
  106. package/dist/data-structures/queue/deque.js.map +1 -1
  107. package/dist/data-structures/queue/index.d.ts +2 -0
  108. package/dist/data-structures/queue/queue.d.ts +107 -0
  109. package/dist/data-structures/queue/queue.js +80 -0
  110. package/dist/data-structures/queue/queue.js.map +1 -1
  111. package/dist/data-structures/stack/index.d.ts +1 -0
  112. package/dist/data-structures/stack/stack.d.ts +63 -0
  113. package/dist/data-structures/stack/stack.js +50 -0
  114. package/dist/data-structures/stack/stack.js.map +1 -1
  115. package/dist/data-structures/tree/index.d.ts +1 -0
  116. package/dist/data-structures/tree/tree.d.ts +14 -0
  117. package/dist/data-structures/tree/tree.js +1 -0
  118. package/dist/data-structures/tree/tree.js.map +1 -1
  119. package/dist/data-structures/trie/index.d.ts +1 -0
  120. package/dist/data-structures/trie/trie.d.ts +61 -0
  121. package/dist/data-structures/trie/trie.js +36 -0
  122. package/dist/data-structures/trie/trie.js.map +1 -1
  123. package/dist/index.d.ts +4 -0
  124. package/dist/interfaces/abstract-binary-tree.d.ts +7 -0
  125. package/dist/interfaces/abstract-graph.d.ts +5 -0
  126. package/dist/interfaces/avl-tree.d.ts +7 -0
  127. package/dist/interfaces/binary-tree.d.ts +6 -0
  128. package/dist/interfaces/bst.d.ts +6 -0
  129. package/dist/interfaces/directed-graph.d.ts +3 -0
  130. package/dist/interfaces/doubly-linked-list.d.ts +1 -0
  131. package/dist/interfaces/heap.d.ts +1 -0
  132. package/dist/interfaces/index.d.ts +15 -0
  133. package/dist/interfaces/navigator.d.ts +1 -0
  134. package/dist/interfaces/priority-queue.d.ts +1 -0
  135. package/dist/interfaces/rb-tree.d.ts +6 -0
  136. package/dist/interfaces/segment-tree.d.ts +1 -0
  137. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  138. package/dist/interfaces/tree-multiset.d.ts +6 -0
  139. package/dist/interfaces/undirected-graph.d.ts +3 -0
  140. package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
  141. package/dist/types/data-structures/abstract-binary-tree.js +6 -0
  142. package/dist/types/data-structures/abstract-binary-tree.js.map +1 -1
  143. package/dist/types/data-structures/abstract-graph.d.ts +11 -0
  144. package/dist/types/data-structures/avl-tree.d.ts +4 -0
  145. package/dist/types/data-structures/binary-tree.d.ts +4 -0
  146. package/dist/types/data-structures/bst.d.ts +13 -0
  147. package/dist/types/data-structures/directed-graph.d.ts +6 -0
  148. package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
  149. package/dist/types/data-structures/hash.d.ts +1 -0
  150. package/dist/types/data-structures/heap.d.ts +3 -0
  151. package/dist/types/data-structures/index.d.ts +16 -0
  152. package/dist/types/data-structures/map-graph.d.ts +1 -0
  153. package/dist/types/data-structures/navigator.d.ts +14 -0
  154. package/dist/types/data-structures/priority-queue.d.ts +7 -0
  155. package/dist/types/data-structures/rb-tree.d.ts +8 -0
  156. package/dist/types/data-structures/segment-tree.d.ts +1 -0
  157. package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
  158. package/dist/types/data-structures/tree-multiset.d.ts +4 -0
  159. package/dist/types/helpers.d.ts +1 -0
  160. package/dist/types/index.d.ts +3 -0
  161. package/dist/types/utils/index.d.ts +2 -0
  162. package/dist/types/utils/utils.d.ts +7 -0
  163. package/dist/types/utils/validate-type.d.ts +19 -0
  164. package/dist/utils/index.d.ts +1 -0
  165. package/dist/utils/utils.d.ts +19 -0
  166. package/package.json +11 -7
  167. package/test/integration/avl-tree.test.ts +4 -4
  168. package/test/integration/bst.test.ts +8 -8
  169. package/test/unit/data-structures/graph/directed-graph.test.ts +5 -5
  170. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  171. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +1 -1
  172. package/test/unit/data-structures/graph/index.ts +0 -2
  173. package/test/unit/data-structures/linked-list/index.ts +0 -4
@@ -3,6 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MapGraph = exports.MapEdge = exports.MapVertex = void 0;
4
4
  const directed_graph_1 = require("./directed-graph");
5
5
  class MapVertex extends directed_graph_1.DirectedVertex {
6
+ /**
7
+ * The constructor function initializes an object with an key, latitude, longitude, and an optional value.
8
+ * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
9
+ * @param {number} lat - The "lat" parameter represents the latitude of a vertex. Latitude is a geographic coordinate
10
+ * that specifies the north-south position of a point on the Earth's surface. It is measured in degrees, with positive
11
+ * values representing points north of the equator and negative values representing points south of the equator.
12
+ * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
13
+ * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
14
+ * values ranging from -180 to 180.
15
+ * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
16
+ * creating an instance of the class.
17
+ */
6
18
  constructor(key, lat, long, val) {
7
19
  super(key, val);
8
20
  this._lat = lat;
@@ -23,12 +35,31 @@ class MapVertex extends directed_graph_1.DirectedVertex {
23
35
  }
24
36
  exports.MapVertex = MapVertex;
25
37
  class MapEdge extends directed_graph_1.DirectedEdge {
38
+ /**
39
+ * The constructor function initializes a new instance of a class with the given source, destination, weight, and
40
+ * value.
41
+ * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
42
+ * a graph.
43
+ * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
44
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
45
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
46
+ * information or data associated with the edge.
47
+ */
26
48
  constructor(src, dest, weight, val) {
27
49
  super(src, dest, weight, val);
28
50
  }
29
51
  }
30
52
  exports.MapEdge = MapEdge;
31
53
  class MapGraph extends directed_graph_1.DirectedGraph {
54
+ /**
55
+ * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
56
+ * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
57
+ * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
58
+ * graph.
59
+ * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
60
+ * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
61
+ * it will default to `undefined`.
62
+ */
32
63
  constructor(origin, bottomRight) {
33
64
  super();
34
65
  this._origin = [0, 0];
@@ -47,9 +78,32 @@ class MapGraph extends directed_graph_1.DirectedGraph {
47
78
  set bottomRight(value) {
48
79
  this._bottomRight = value;
49
80
  }
81
+ /**
82
+ * The function creates a new vertex with the given key, value, latitude, and longitude.
83
+ * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
84
+ * be a string or a number depending on how you define it in your code.
85
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
86
+ * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
87
+ * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
88
+ * position of the vertex on the Earth's surface in the north-south direction.
89
+ * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
90
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
91
+ */
50
92
  createVertex(key, val, lat = this.origin[0], long = this.origin[1]) {
51
93
  return new MapVertex(key, lat, long, val);
52
94
  }
95
+ /**
96
+ * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
97
+ * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
98
+ * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge being
99
+ * created.
100
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
101
+ * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
102
+ * If the weight is not provided, it can be set to a default value or left undefined.
103
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
104
+ * depending on the specific implementation of the `MapEdge` class.
105
+ * @returns a new instance of the `MapEdge` class, casted as type `E`.
106
+ */
53
107
  createEdge(src, dest, weight, val) {
54
108
  return new MapEdge(src, dest, weight, val);
55
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"map-graph.js","sourceRoot":"","sources":["../../../src/data-structures/graph/map-graph.ts"],"names":[],"mappings":";;;AACA,qDAA6E;AAE7E,MAAa,SAAmB,SAAQ,+BAAiB;IAavD,YAAY,GAAc,EAAE,GAAW,EAAE,IAAY,EAAE,GAAO;QAC5D,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAID,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,GAAG,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAID,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAtCD,8BAsCC;AAED,MAAa,OAAiB,SAAQ,6BAAe;IAWnD,YAAY,GAAc,EAAE,IAAe,EAAE,MAAe,EAAE,GAAO;QACnE,K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K,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;OAUG;IACM,YAAY,CACnB,GAAc,EACd,GAAc,EACd,MAAc,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAC5B,OAAe,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAE7B,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAM,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;OAWG;IACM,UAAU,CAAC,GAAc,EAAE,IAAe,EAAE,MAAe,EAAE,GAAc;QAClF,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAM,CAAC;IAClD,CAAC;CACF;AA1ED,4BA0EC"}
@@ -0,0 +1,127 @@
1
+ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
+ import type { VertexKey } from '../../types';
3
+ import { IUNDirectedGraph } from '../../interfaces';
4
+ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
5
+ /**
6
+ * The constructor function initializes a vertex with an optional value.
7
+ * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
8
+ * used to uniquely identify the vertex within a graph or network.
9
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
10
+ * vertex. If no value is provided, the vertex will be initialized with a default value.
11
+ */
12
+ constructor(key: VertexKey, val?: V);
13
+ }
14
+ export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
15
+ /**
16
+ * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
+ * value.
18
+ * @param {VertexKey} v1 - The first vertex ID of the edge.
19
+ * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
20
+ * graph edge.
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
23
+ * with the edge.
24
+ */
25
+ constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: V);
26
+ private _vertices;
27
+ get vertices(): [VertexKey, VertexKey];
28
+ set vertices(v: [VertexKey, VertexKey]);
29
+ }
30
+ export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IUNDirectedGraph<V, E> {
31
+ /**
32
+ * The constructor initializes a new Map object to store edges.
33
+ */
34
+ constructor();
35
+ protected _edges: Map<V, E[]>;
36
+ get edges(): Map<V, E[]>;
37
+ /**
38
+ * The function creates a new vertex with an optional value and returns it.
39
+ * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
40
+ * vertex from another in the graph.
41
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
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
+ * the vertex.
44
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
45
+ */
46
+ createVertex(key: VertexKey, val?: V['val']): V;
47
+ /**
48
+ * The function creates an undirected edge between two vertices with an optional weight and value.
49
+ * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
50
+ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
51
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
52
+ * no weight is provided, it defaults to 1.
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
+ * 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`.
56
+ */
57
+ createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: E['val']): E;
58
+ /**
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
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
63
+ * object), `null`, or `VertexKey` (vertex ID).
64
+ * @returns an edge (E) or null.
65
+ */
66
+ getEdge(v1: V | null | VertexKey, v2: V | null | VertexKey): E | null;
67
+ /**
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
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.
73
+ */
74
+ removeEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
75
+ /**
76
+ * The removeEdge 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.
79
+ */
80
+ removeEdge(edge: E): E | null;
81
+ /**
82
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
83
+ * vertex.
84
+ * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
85
+ * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
86
+ * edges connected to that vertex.
87
+ */
88
+ degreeOf(vertexOrKey: VertexKey | V): number;
89
+ /**
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.
93
+ * @returns an array of edges.
94
+ */
95
+ edgesOf(vertexOrKey: VertexKey | V): E[];
96
+ /**
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[]`.
99
+ */
100
+ edgeSet(): E[];
101
+ /**
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
104
+ * (`VertexKey`).
105
+ * @returns an array of vertices (V[]).
106
+ */
107
+ getNeighbors(vertexOrKey: V | VertexKey): V[];
108
+ /**
109
+ * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
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
113
+ * graph. If the edge does not exist, it returns `null`.
114
+ */
115
+ getEndsOfEdge(edge: E): [V, V] | null;
116
+ /**
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.
119
+ * @returns a boolean value.
120
+ */
121
+ protected _addEdgeOnly(edge: E): boolean;
122
+ /**
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.
125
+ */
126
+ protected _setEdges(v: Map<V, E[]>): void;
127
+ }
@@ -1,15 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UndirectedGraph = exports.UndirectedEdge = exports.UndirectedVertex = void 0;
4
+ /**
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
10
+ */
4
11
  const utils_1 = require("../../utils");
5
12
  const abstract_graph_1 = require("./abstract-graph");
6
13
  class UndirectedVertex extends abstract_graph_1.AbstractVertex {
14
+ /**
15
+ * The constructor function initializes a vertex with an optional value.
16
+ * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
17
+ * used to uniquely identify the vertex within a graph or network.
18
+ * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
19
+ * vertex. If no value is provided, the vertex will be initialized with a default value.
20
+ */
7
21
  constructor(key, val) {
8
22
  super(key, val);
9
23
  }
10
24
  }
11
25
  exports.UndirectedVertex = UndirectedVertex;
12
26
  class UndirectedEdge extends abstract_graph_1.AbstractEdge {
27
+ /**
28
+ * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
29
+ * value.
30
+ * @param {VertexKey} v1 - The first vertex ID of the edge.
31
+ * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
32
+ * graph edge.
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
35
+ * with the edge.
36
+ */
13
37
  constructor(v1, v2, weight, val) {
14
38
  super(weight, val);
15
39
  this._vertices = [v1, v2];
@@ -23,6 +47,9 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
23
47
  }
24
48
  exports.UndirectedEdge = UndirectedEdge;
25
49
  class UndirectedGraph extends abstract_graph_1.AbstractGraph {
50
+ /**
51
+ * The constructor initializes a new Map object to store edges.
52
+ */
26
53
  constructor() {
27
54
  super();
28
55
  this._edges = new Map();
@@ -30,12 +57,39 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
30
57
  get edges() {
31
58
  return this._edges;
32
59
  }
60
+ /**
61
+ * The function creates a new vertex with an optional value and returns it.
62
+ * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
63
+ * vertex from another in the graph.
64
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
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
+ * the vertex.
67
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
68
+ */
33
69
  createVertex(key, val) {
34
70
  return new UndirectedVertex(key, val !== null && val !== void 0 ? val : key);
35
71
  }
72
+ /**
73
+ * The function creates an undirected edge between two vertices with an optional weight and value.
74
+ * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
75
+ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
76
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
77
+ * no weight is provided, it defaults to 1.
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
+ * 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`.
81
+ */
36
82
  createEdge(v1, v2, weight, val) {
37
83
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
38
84
  }
85
+ /**
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
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
90
+ * object), `null`, or `VertexKey` (vertex ID).
91
+ * @returns an edge (E) or null.
92
+ */
39
93
  getEdge(v1, v2) {
40
94
  var _a;
41
95
  let edges = [];
@@ -48,6 +102,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
48
102
  }
49
103
  return edges ? edges[0] || null : null;
50
104
  }
105
+ /**
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
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.
111
+ */
51
112
  removeEdgeBetween(v1, v2) {
52
113
  const vertex1 = this._getVertex(v1);
53
114
  const vertex2 = this._getVertex(v2);
@@ -65,9 +126,21 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
65
126
  }
66
127
  return removed;
67
128
  }
129
+ /**
130
+ * The removeEdge 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.
133
+ */
68
134
  removeEdge(edge) {
69
135
  return this.removeEdgeBetween(edge.vertices[0], edge.vertices[1]);
70
136
  }
137
+ /**
138
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
139
+ * vertex.
140
+ * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
141
+ * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
142
+ * edges connected to that vertex.
143
+ */
71
144
  degreeOf(vertexOrKey) {
72
145
  var _a;
73
146
  const vertex = this._getVertex(vertexOrKey);
@@ -78,6 +151,12 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
78
151
  return 0;
79
152
  }
80
153
  }
154
+ /**
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.
158
+ * @returns an array of edges.
159
+ */
81
160
  edgesOf(vertexOrKey) {
82
161
  const vertex = this._getVertex(vertexOrKey);
83
162
  if (vertex) {
@@ -87,6 +166,10 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
87
166
  return [];
88
167
  }
89
168
  }
169
+ /**
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[]`.
172
+ */
90
173
  edgeSet() {
91
174
  const edgeSet = new Set();
92
175
  this._edges.forEach(edges => {
@@ -96,6 +179,12 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
96
179
  });
97
180
  return [...edgeSet];
98
181
  }
182
+ /**
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
185
+ * (`VertexKey`).
186
+ * @returns an array of vertices (V[]).
187
+ */
99
188
  getNeighbors(vertexOrKey) {
100
189
  const neighbors = [];
101
190
  const vertex = this._getVertex(vertexOrKey);
@@ -110,6 +199,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
110
199
  }
111
200
  return neighbors;
112
201
  }
202
+ /**
203
+ * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
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
207
+ * graph. If the edge does not exist, it returns `null`.
208
+ */
113
209
  getEndsOfEdge(edge) {
114
210
  if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
115
211
  return null;
@@ -123,6 +219,11 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
123
219
  return null;
124
220
  }
125
221
  }
222
+ /**
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.
225
+ * @returns a boolean value.
226
+ */
126
227
  _addEdgeOnly(edge) {
127
228
  for (const end of edge.vertices) {
128
229
  const endVertex = this._getVertex(end);
@@ -140,6 +241,10 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
140
241
  }
141
242
  return true;
142
243
  }
244
+ /**
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.
247
+ */
143
248
  _setEdges(v) {
144
249
  this._edges = v;
145
250
  }
@@ -1 +1 @@
1
- {"version":3,"file":"undirected-graph.js","sourceRoot":"","sources":["../../../src/data-structures/graph/undirected-graph.ts"],"names":[],"mappings":";;;AAOA,uCAAwC;AACxC,qDAA6E;AAI7E,MAA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S,CAAC,CAAC;gBACzC,IAAI,KAAK,EAAE;oBACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAClB;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;iBACpC;aACF;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAMS,SAAS,CAAC,CAAc;QAChC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA7ND,0CA6NC"}
1
+ {"version":3,"file":"undirected-graph.js","sourceRoot":"","sources":["../../../src/data-structures/graph/undirected-graph.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,uCAAwC;AACxC,qDAA6E;AAI7E,MAAa,gBAA0B,SAAQ,+BAAiB;IAC9D;;;;;;OAMG;IACH,YAAY,GAAc,EAAE,GAAO;QACjC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAXD,4CAWC;AAED,MAAa,cAA2B,SAAQ,6BAAe;IAC7D;;;;;;;;;OASG;IACH,YAAY,EAAa,EAAE,EAAa,EAAE,MAAe,EAAE,GAAO;QAChE,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC;IAID,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,QAAQ,CAAC,CAAyB;QACpC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACrB,CAAC;CACF;AAzBD,wCAyBC;AAED,MAAa,eAIX,SAAQ,8BAAmB;IAG3B;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;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Q,CAAC,CAAC,CAAC,CAAC,EAAE;YACrD,OAAO,IAAI,CAAC;SACb;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;SACjB;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED;;;;OAIG;IACO,YAAY,CAAC,IAAO;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,SAAS,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YACrC,IAAI,SAAS,EAAE;gBACb,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACzC,IAAI,KAAK,EAAE;oBACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAClB;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;iBACpC;aACF;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,CAAc;QAChC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA7ND,0CA6NC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ export declare class CoordinateMap<V> extends Map<any, V> {
9
+ constructor(joint?: string);
10
+ protected _joint: string;
11
+ get joint(): string;
12
+ /**
13
+ * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
14
+ * key array with a specified delimiter.
15
+ * @param {number[]} key - The parameter "key" is an array of numbers.
16
+ * @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
17
+ * (`super.has`) with the `key` array joined together using the `_joint` property.
18
+ */
19
+ has(key: number[]): boolean;
20
+ /**
21
+ * The function overrides the set method of a Map object to convert the key from an array to a string using a specified
22
+ * delimiter before calling the original set method.
23
+ * @param {number[]} key - The key parameter is an array of numbers.
24
+ * @param {V} value - The value parameter is the value that you want to associate with the specified key.
25
+ * @returns The `set` method is returning the result of calling the `set` method of the superclass
26
+ * (`super.set(key.join(this._joint), value)`).
27
+ */
28
+ set(key: number[], value: V): this;
29
+ /**
30
+ * The function overrides the get method to join the key array with a specified joint and then calls the super get
31
+ * method.
32
+ * @param {number[]} key - An array of numbers
33
+ * @returns The code is returning the value associated with the specified key in the map.
34
+ */
35
+ get(key: number[]): V | undefined;
36
+ /**
37
+ * The function overrides the delete method and joins the key array using a specified joint character before calling
38
+ * the super delete method.
39
+ * @param {number[]} key - An array of numbers that represents the key to be deleted.
40
+ * @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
41
+ * `key` array joined together using the `_joint` property.
42
+ */
43
+ delete(key: number[]): boolean;
44
+ protected _setJoint(v: string): void;
45
+ }
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoordinateMap = void 0;
4
+ /**
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
10
+ */
4
11
  class CoordinateMap extends Map {
5
12
  constructor(joint) {
6
13
  super();
@@ -11,15 +18,43 @@ class CoordinateMap extends Map {
11
18
  get joint() {
12
19
  return this._joint;
13
20
  }
21
+ /**
22
+ * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
23
+ * key array with a specified delimiter.
24
+ * @param {number[]} key - The parameter "key" is an array of numbers.
25
+ * @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
26
+ * (`super.has`) with the `key` array joined together using the `_joint` property.
27
+ */
14
28
  has(key) {
15
29
  return super.has(key.join(this._joint));
16
30
  }
31
+ /**
32
+ * The function overrides the set method of a Map object to convert the key from an array to a string using a specified
33
+ * delimiter before calling the original set method.
34
+ * @param {number[]} key - The key parameter is an array of numbers.
35
+ * @param {V} value - The value parameter is the value that you want to associate with the specified key.
36
+ * @returns The `set` method is returning the result of calling the `set` method of the superclass
37
+ * (`super.set(key.join(this._joint), value)`).
38
+ */
17
39
  set(key, value) {
18
40
  return super.set(key.join(this._joint), value);
19
41
  }
42
+ /**
43
+ * The function overrides the get method to join the key array with a specified joint and then calls the super get
44
+ * method.
45
+ * @param {number[]} key - An array of numbers
46
+ * @returns The code is returning the value associated with the specified key in the map.
47
+ */
20
48
  get(key) {
21
49
  return super.get(key.join(this._joint));
22
50
  }
51
+ /**
52
+ * The function overrides the delete method and joins the key array using a specified joint character before calling
53
+ * the super delete method.
54
+ * @param {number[]} key - An array of numbers that represents the key to be deleted.
55
+ * @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
56
+ * `key` array joined together using the `_joint` property.
57
+ */
23
58
  delete(key) {
24
59
  return super.delete(key.join(this._joint));
25
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate-map.js","sourceRoot":"","sources":["../../../src/data-structures/hash/coordinate-map.ts"],"names":[],"mappings":";;;AAOA,MAAa,aAAiB,SAAQ,GAAW;IAC/C,YAAY,KAAc;QACxB,KAAK,EAAE,CAAC;QAIA,WAAM,GAAG,GAAG,CAAC;QAHrB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IAC/C,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IAC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AQ;QAClC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACM,GAAG,CAAC,GAAa;QACxB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACM,MAAM,CAAC,GAAa;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,CAAC;IAES,SAAS,CAAC,CAAS;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA3DD,sCA2DC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ export declare class CoordinateSet extends Set<any> {
9
+ constructor(joint?: string);
10
+ protected _joint: string;
11
+ get joint(): string;
12
+ /**
13
+ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
14
+ * joining its elements with a specified separator.
15
+ * @param {number[]} value - The parameter "value" is an array of numbers.
16
+ * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
17
+ * in the joined value as an argument.
18
+ */
19
+ has(value: number[]): boolean;
20
+ /**
21
+ * The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
22
+ * specified delimiter before calling the parent class's "add" function.
23
+ * @param {number[]} value - An array of numbers
24
+ * @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
25
+ * (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
26
+ */
27
+ add(value: number[]): this;
28
+ /**
29
+ * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
30
+ * array with a specified joint and then calling the delete method of the parent class.
31
+ * @param {number[]} value - An array of numbers
32
+ * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
33
+ * `value` array joined together using the `_joint` property.
34
+ */
35
+ delete(value: number[]): boolean;
36
+ protected _setJoint(v: string): void;
37
+ }
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoordinateSet = void 0;
4
+ /**
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
10
+ */
4
11
  class CoordinateSet extends Set {
5
12
  constructor(joint) {
6
13
  super();
@@ -11,12 +18,33 @@ class CoordinateSet extends Set {
11
18
  get joint() {
12
19
  return this._joint;
13
20
  }
21
+ /**
22
+ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
23
+ * joining its elements with a specified separator.
24
+ * @param {number[]} value - The parameter "value" is an array of numbers.
25
+ * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
26
+ * in the joined value as an argument.
27
+ */
14
28
  has(value) {
15
29
  return super.has(value.join(this._joint));
16
30
  }
31
+ /**
32
+ * The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
33
+ * specified delimiter before calling the parent class's "add" function.
34
+ * @param {number[]} value - An array of numbers
35
+ * @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
36
+ * (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
37
+ */
17
38
  add(value) {
18
39
  return super.add(value.join(this._joint));
19
40
  }
41
+ /**
42
+ * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
43
+ * array with a specified joint and then calling the delete method of the parent class.
44
+ * @param {number[]} value - An array of numbers
45
+ * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
46
+ * `value` array joined together using the `_joint` property.
47
+ */
20
48
  delete(value) {
21
49
  return super.delete(value.join(this._joint));
22
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate-set.js","sourceRoot":"","sources":["../../../src/data-structures/hash/coordinate-set.ts"],"names":[],"mappings":";;;AAOA,MAAa,aAAc,SAAQ,GAAQ;IACzC,YAAY,KAAc;QACxB,KAAK,EAAE,CAAC;QAIA,WAAM,GAAG,GAAG,CAAC;QAHrB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IAC/C,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IASQ,GAAG,CAAC,KAAe;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;IASQ,GAAG,CAAC,KAAe;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;IASQ,MAAM,CAAC,KAAe;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;IAES,SAAS,CAAC,CAAS;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAhDD,sCAgDC"}
1
+ {"version":3,"file":"coordinate-set.js","sourceRoot":"","sources":["../../../src/data-structures/hash/coordinate-set.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,GAAQ;IACzC,YAAY,KAAc;QACxB,KAAK,EAAE,CAAC;QAIA,WAAM,GAAG,GAAG,CAAC;QAHrB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IAC/C,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACM,GAAG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