data-structure-typed 1.15.0 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +378 -7
  2. package/dist/data-structures/binary-tree/binary-tree.d.ts +30 -30
  3. package/dist/data-structures/binary-tree/binary-tree.js +55 -55
  4. package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -17
  5. package/dist/data-structures/binary-tree/segment-tree.js +30 -30
  6. package/dist/data-structures/graph/abstract-graph.d.ts +6 -6
  7. package/dist/data-structures/graph/abstract-graph.js +6 -6
  8. package/dist/data-structures/graph/directed-graph.d.ts +4 -4
  9. package/dist/data-structures/graph/directed-graph.js +6 -6
  10. package/dist/data-structures/graph/undirected-graph.d.ts +3 -3
  11. package/dist/data-structures/hash/coordinate-map.d.ts +2 -2
  12. package/dist/data-structures/hash/coordinate-set.d.ts +2 -2
  13. package/dist/data-structures/heap/heap.d.ts +14 -14
  14. package/dist/data-structures/heap/heap.js +12 -12
  15. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +9 -9
  16. package/dist/data-structures/linked-list/doubly-linked-list.js +12 -12
  17. package/dist/data-structures/linked-list/singly-linked-list.d.ts +7 -7
  18. package/dist/data-structures/priority-queue/priority-queue.d.ts +7 -7
  19. package/dist/data-structures/priority-queue/priority-queue.js +6 -6
  20. package/dist/data-structures/queue/deque.d.ts +1 -1
  21. package/dist/utils/types/utils.d.ts +0 -52
  22. package/dist/utils/types/utils.js +0 -52
  23. package/dist/utils/utils.d.ts +1 -97
  24. package/dist/utils/utils.js +1 -547
  25. package/package.json +3 -4
  26. package/src/assets/overview-diagram-of-data-structures.png +0 -0
  27. package/src/data-structures/binary-tree/binary-tree.ts +83 -76
  28. package/src/data-structures/binary-tree/segment-tree.ts +55 -36
  29. package/src/data-structures/graph/abstract-graph.ts +21 -19
  30. package/src/data-structures/graph/directed-graph.ts +23 -18
  31. package/src/data-structures/graph/undirected-graph.ts +16 -11
  32. package/src/data-structures/hash/coordinate-map.ts +11 -8
  33. package/src/data-structures/hash/coordinate-set.ts +11 -8
  34. package/src/data-structures/heap/heap.ts +34 -28
  35. package/src/data-structures/linked-list/doubly-linked-list.ts +40 -26
  36. package/src/data-structures/linked-list/singly-linked-list.ts +32 -23
  37. package/src/data-structures/priority-queue/priority-queue.ts +17 -14
  38. package/src/data-structures/queue/deque.ts +14 -4
  39. package/src/utils/types/utils.ts +1 -175
  40. package/src/utils/utils.ts +1 -484
  41. package/tests/unit/data-structures/binary-tree/bst.test.ts +40 -31
  42. package/tests/unit/data-structures/graph/directed-graph.test.ts +31 -34
@@ -1,29 +1,5 @@
1
1
  import {DirectedEdge, DirectedGraph, DirectedVertex, VertexId} from '../../../../src';
2
2
 
3
- class MyVertex extends DirectedVertex {
4
- data: string;
5
-
6
- constructor(id: VertexId, data: string) {
7
- super(id);
8
- this.data = data;
9
- }
10
- }
11
-
12
- class MyEdge extends DirectedEdge {
13
- data: string;
14
-
15
- constructor(v1: VertexId, v2: VertexId, weight: number, data: string) {
16
- super(v1, v2, weight);
17
- this.data = data;
18
- }
19
- }
20
-
21
- class MyGraph<V extends MyVertex, E extends MyEdge> extends DirectedGraph<V, E> {
22
- constructor() {
23
- super();
24
- }
25
- }
26
-
27
3
  describe('DirectedGraph Test1', () => {
28
4
  let graph: DirectedGraph<DirectedVertex, DirectedEdge>;
29
5
 
@@ -69,10 +45,7 @@ describe('DirectedGraph Test1', () => {
69
45
  expect(graph.hasEdge('A', 'B')).toBe(false);
70
46
  });
71
47
 
72
- // Add more test cases for other methods...
73
-
74
48
  it('should perform topological sort', () => {
75
- // Create a graph with vertices and edges
76
49
  const vertexA = new DirectedVertex('A');
77
50
  const vertexB = new DirectedVertex('B');
78
51
  const vertexC = new DirectedVertex('C');
@@ -85,17 +58,43 @@ describe('DirectedGraph Test1', () => {
85
58
  graph.addEdge(edgeAB);
86
59
  graph.addEdge(edgeBC);
87
60
 
88
- // Perform topological sort
89
61
  const topologicalOrder = graph.topologicalSort();
90
-
91
62
  if (topologicalOrder) expect(topologicalOrder.map(v => v.id)).toEqual(['A', 'B', 'C']);
92
-
93
63
  });
94
-
95
- // Add more test cases for other methods...
96
64
  });
97
65
 
98
66
 
67
+ class MyVertex extends DirectedVertex {
68
+ private _data: string;
69
+ get data(): string {
70
+ return this._data;
71
+ }
72
+ set data(value: string) {
73
+ this._data = value;
74
+ }
75
+
76
+ constructor(id: VertexId, data: string) {
77
+ super(id);
78
+ this._data = data;
79
+ }
80
+ }
81
+
82
+ class MyEdge extends DirectedEdge {
83
+ private _data: string;
84
+ get data(): string {
85
+ return this._data;
86
+ }
87
+ set data(value: string) {
88
+ this._data = value;
89
+ }
90
+
91
+ constructor(v1: VertexId, v2: VertexId, weight: number, data: string) {
92
+ super(v1, v2, weight);
93
+ this._data = data;
94
+ }
95
+ }
96
+
97
+
99
98
  describe('DirectedGraph Test2 operations', () => {
100
99
  const myGraph = new DirectedGraph<MyVertex, MyEdge>();
101
100
 
@@ -223,8 +222,6 @@ describe('DirectedGraph Test3', () => {
223
222
  expect(myGraph.getEdge(2, 1)).toBeTruthy();
224
223
  expect(myGraph.getEdge(1, '100')).toBeFalsy();
225
224
 
226
- // Add the rest of your assertions here...
227
-
228
225
  myGraph.removeEdgeBetween(1, 2);
229
226
  expect(myGraph.getEdge(1, 2)).toBeFalsy();
230
227