min-heap-typed 1.39.6 → 1.40.0

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 (93) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.js +0 -1
  2. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  4. package/dist/data-structures/binary-tree/binary-tree.d.ts +5 -20
  5. package/dist/data-structures/binary-tree/binary-tree.js +8 -29
  6. package/dist/data-structures/binary-tree/bst.d.ts +1 -1
  7. package/dist/data-structures/binary-tree/bst.js +3 -3
  8. package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -3
  9. package/dist/data-structures/binary-tree/rb-tree.js +1 -7
  10. package/dist/data-structures/binary-tree/segment-tree.d.ts +10 -26
  11. package/dist/data-structures/binary-tree/segment-tree.js +10 -58
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.js +6 -6
  14. package/dist/data-structures/graph/abstract-graph.d.ts +5 -24
  15. package/dist/data-structures/graph/abstract-graph.js +4 -43
  16. package/dist/data-structures/graph/directed-graph.d.ts +4 -10
  17. package/dist/data-structures/graph/directed-graph.js +2 -20
  18. package/dist/data-structures/graph/map-graph.d.ts +4 -10
  19. package/dist/data-structures/graph/map-graph.js +2 -20
  20. package/dist/data-structures/graph/undirected-graph.d.ts +1 -8
  21. package/dist/data-structures/graph/undirected-graph.js +1 -14
  22. package/dist/data-structures/hash/coordinate-map.d.ts +0 -1
  23. package/dist/data-structures/hash/coordinate-map.js +0 -3
  24. package/dist/data-structures/hash/coordinate-set.d.ts +0 -1
  25. package/dist/data-structures/hash/coordinate-set.js +0 -3
  26. package/dist/data-structures/hash/hash-map.d.ts +8 -14
  27. package/dist/data-structures/hash/hash-map.js +4 -22
  28. package/dist/data-structures/hash/hash-table.d.ts +6 -9
  29. package/dist/data-structures/hash/hash-table.js +0 -9
  30. package/dist/data-structures/heap/heap.d.ts +12 -6
  31. package/dist/data-structures/heap/heap.js +40 -22
  32. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +6 -14
  33. package/dist/data-structures/linked-list/doubly-linked-list.js +18 -42
  34. package/dist/data-structures/linked-list/singly-linked-list.d.ts +5 -11
  35. package/dist/data-structures/linked-list/singly-linked-list.js +17 -35
  36. package/dist/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  37. package/dist/data-structures/linked-list/skip-linked-list.js +62 -17
  38. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  39. package/dist/data-structures/matrix/matrix2d.d.ts +1 -1
  40. package/dist/data-structures/matrix/navigator.d.ts +4 -4
  41. package/dist/data-structures/queue/deque.d.ts +8 -12
  42. package/dist/data-structures/queue/deque.js +31 -43
  43. package/dist/data-structures/queue/queue.d.ts +20 -5
  44. package/dist/data-structures/queue/queue.js +35 -18
  45. package/dist/data-structures/stack/stack.d.ts +2 -1
  46. package/dist/data-structures/stack/stack.js +10 -7
  47. package/dist/data-structures/tree/tree.d.ts +3 -9
  48. package/dist/data-structures/tree/tree.js +3 -21
  49. package/dist/data-structures/trie/trie.d.ts +6 -12
  50. package/dist/data-structures/trie/trie.js +6 -24
  51. package/dist/interfaces/binary-tree.d.ts +1 -1
  52. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  53. package/package.json +2 -2
  54. package/src/data-structures/binary-tree/avl-tree.ts +2 -4
  55. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -15
  56. package/src/data-structures/binary-tree/binary-tree.ts +17 -42
  57. package/src/data-structures/binary-tree/bst.ts +5 -6
  58. package/src/data-structures/binary-tree/rb-tree.ts +13 -21
  59. package/src/data-structures/binary-tree/segment-tree.ts +16 -83
  60. package/src/data-structures/binary-tree/tree-multiset.ts +8 -9
  61. package/src/data-structures/graph/abstract-graph.ts +21 -67
  62. package/src/data-structures/graph/directed-graph.ts +13 -39
  63. package/src/data-structures/graph/map-graph.ts +7 -32
  64. package/src/data-structures/graph/undirected-graph.ts +9 -26
  65. package/src/data-structures/hash/coordinate-map.ts +0 -4
  66. package/src/data-structures/hash/coordinate-set.ts +0 -4
  67. package/src/data-structures/hash/hash-map.ts +13 -37
  68. package/src/data-structures/hash/hash-table.ts +6 -18
  69. package/src/data-structures/hash/tree-map.ts +2 -1
  70. package/src/data-structures/hash/tree-set.ts +2 -1
  71. package/src/data-structures/heap/heap.ts +58 -30
  72. package/src/data-structures/heap/max-heap.ts +1 -1
  73. package/src/data-structures/heap/min-heap.ts +1 -1
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +26 -60
  75. package/src/data-structures/linked-list/singly-linked-list.ts +24 -49
  76. package/src/data-structures/linked-list/skip-linked-list.ts +73 -25
  77. package/src/data-structures/matrix/matrix.ts +2 -2
  78. package/src/data-structures/matrix/matrix2d.ts +1 -1
  79. package/src/data-structures/matrix/navigator.ts +4 -4
  80. package/src/data-structures/matrix/vector2d.ts +2 -1
  81. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  82. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  83. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  84. package/src/data-structures/queue/deque.ts +38 -53
  85. package/src/data-structures/queue/queue.ts +38 -20
  86. package/src/data-structures/stack/stack.ts +13 -9
  87. package/src/data-structures/tree/tree.ts +7 -33
  88. package/src/data-structures/trie/trie.ts +14 -40
  89. package/src/interfaces/binary-tree.ts +1 -1
  90. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  91. package/src/types/data-structures/matrix/navigator.ts +1 -1
  92. package/src/types/utils/utils.ts +1 -1
  93. package/src/types/utils/validate-type.ts +2 -2
@@ -37,20 +37,8 @@ class DirectedEdge extends abstract_graph_1.AbstractEdge {
37
37
  */
38
38
  constructor(src, dest, weight, value) {
39
39
  super(weight, value);
40
- this._src = src;
41
- this._dest = dest;
42
- }
43
- get src() {
44
- return this._src;
45
- }
46
- set src(v) {
47
- this._src = v;
48
- }
49
- get dest() {
50
- return this._dest;
51
- }
52
- set dest(v) {
53
- this._dest = v;
40
+ this.src = src;
41
+ this.dest = dest;
54
42
  }
55
43
  }
56
44
  exports.DirectedEdge = DirectedEdge;
@@ -412,11 +400,5 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
412
400
  return false;
413
401
  }
414
402
  }
415
- _setOutEdgeMap(value) {
416
- this._outEdgeMap = value;
417
- }
418
- _setInEdgeMap(value) {
419
- this._inEdgeMap = value;
420
- }
421
403
  }
422
404
  exports.DirectedGraph = DirectedGraph;
@@ -1,6 +1,8 @@
1
1
  import { MapGraphCoordinate, VertexKey } from '../../types';
2
2
  import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
3
3
  export declare class MapVertex<V = any> extends DirectedVertex<V> {
4
+ lat: number;
5
+ long: number;
4
6
  /**
5
7
  * The constructor function initializes an object with an key, latitude, longitude, and an optional value.
6
8
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
@@ -14,12 +16,6 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
14
16
  * creating an instance of the class.
15
17
  */
16
18
  constructor(key: VertexKey, value: V, lat: number, long: number);
17
- private _lat;
18
- get lat(): number;
19
- set lat(value: number);
20
- private _long;
21
- get long(): number;
22
- set long(value: number);
23
19
  }
24
20
  export declare class MapEdge<E = any> extends DirectedEdge<E> {
25
21
  /**
@@ -45,12 +41,10 @@ export declare class MapGraph<V = any, E = any, VO extends MapVertex<V> = MapVer
45
41
  * it will default to `undefined`.
46
42
  */
47
43
  constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
48
- private _origin;
44
+ protected _origin: MapGraphCoordinate;
49
45
  get origin(): MapGraphCoordinate;
50
- set origin(value: MapGraphCoordinate);
51
- private _bottomRight;
46
+ protected _bottomRight: MapGraphCoordinate | undefined;
52
47
  get bottomRight(): MapGraphCoordinate | undefined;
53
- set bottomRight(value: MapGraphCoordinate | undefined);
54
48
  /**
55
49
  * The function creates a new vertex with the given key, value, latitude, and longitude.
56
50
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
@@ -17,20 +17,8 @@ class MapVertex extends directed_graph_1.DirectedVertex {
17
17
  */
18
18
  constructor(key, value, lat, long) {
19
19
  super(key, value);
20
- this._lat = lat;
21
- this._long = long;
22
- }
23
- get lat() {
24
- return this._lat;
25
- }
26
- set lat(value) {
27
- this._lat = value;
28
- }
29
- get long() {
30
- return this._long;
31
- }
32
- set long(value) {
33
- this._long = value;
20
+ this.lat = lat;
21
+ this.long = long;
34
22
  }
35
23
  }
36
24
  exports.MapVertex = MapVertex;
@@ -69,15 +57,9 @@ class MapGraph extends directed_graph_1.DirectedGraph {
69
57
  get origin() {
70
58
  return this._origin;
71
59
  }
72
- set origin(value) {
73
- this._origin = value;
74
- }
75
60
  get bottomRight() {
76
61
  return this._bottomRight;
77
62
  }
78
- set bottomRight(value) {
79
- this._bottomRight = value;
80
- }
81
63
  /**
82
64
  * The function creates a new vertex with the given key, value, latitude, and longitude.
83
65
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
@@ -12,6 +12,7 @@ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
12
12
  constructor(key: VertexKey, value?: V);
13
13
  }
14
14
  export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
15
+ vertices: [VertexKey, VertexKey];
15
16
  /**
16
17
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
18
  * value.
@@ -23,9 +24,6 @@ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
23
24
  * with the edge.
24
25
  */
25
26
  constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
26
- private _vertices;
27
- get vertices(): [VertexKey, VertexKey];
28
- set vertices(v: [VertexKey, VertexKey]);
29
27
  }
30
28
  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
29
  /**
@@ -119,9 +117,4 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
119
117
  * @returns a boolean value.
120
118
  */
121
119
  protected _addEdgeOnly(edge: EO): boolean;
122
- /**
123
- * The function sets the edges of a graph.
124
- * @param v - A map where the keys are of type VO and the values are arrays of type EO.
125
- */
126
- protected _setEdges(v: Map<VO, EO[]>): void;
127
120
  }
@@ -36,13 +36,7 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
36
36
  */
37
37
  constructor(v1, v2, weight, value) {
38
38
  super(weight, value);
39
- this._vertices = [v1, v2];
40
- }
41
- get vertices() {
42
- return this._vertices;
43
- }
44
- set vertices(v) {
45
- this._vertices = v;
39
+ this.vertices = [v1, v2];
46
40
  }
47
41
  }
48
42
  exports.UndirectedEdge = UndirectedEdge;
@@ -241,12 +235,5 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
241
235
  }
242
236
  return true;
243
237
  }
244
- /**
245
- * The function sets the edges of a graph.
246
- * @param v - A map where the keys are of type VO and the values are arrays of type EO.
247
- */
248
- _setEdges(v) {
249
- this._edges = v;
250
- }
251
238
  }
252
239
  exports.UndirectedGraph = UndirectedGraph;
@@ -41,5 +41,4 @@ export declare class CoordinateMap<V> extends Map<any, V> {
41
41
  * `key` array joined together using the `_joint` property.
42
42
  */
43
43
  delete(key: number[]): boolean;
44
- protected _setJoint(v: string): void;
45
44
  }
@@ -58,8 +58,5 @@ class CoordinateMap extends Map {
58
58
  delete(key) {
59
59
  return super.delete(key.join(this._joint));
60
60
  }
61
- _setJoint(v) {
62
- this._joint = v;
63
- }
64
61
  }
65
62
  exports.CoordinateMap = CoordinateMap;
@@ -33,5 +33,4 @@ export declare class CoordinateSet extends Set<any> {
33
33
  * `value` array joined together using the `_joint` property.
34
34
  */
35
35
  delete(value: number[]): boolean;
36
- protected _setJoint(v: string): void;
37
36
  }
@@ -48,8 +48,5 @@ class CoordinateSet extends Set {
48
48
  delete(value) {
49
49
  return super.delete(value.join(this._joint));
50
50
  }
51
- _setJoint(v) {
52
- this._joint = v;
53
- }
54
51
  }
55
52
  exports.CoordinateSet = CoordinateSet;
@@ -20,24 +20,18 @@ export declare class HashMap<K, V> {
20
20
  * default hash function converts the key to a string, calculates the sum of the
21
21
  */
22
22
  constructor(initialCapacity?: number, loadFactor?: number, hashFn?: HashFunction<K>);
23
- private _initialCapacity;
23
+ protected _initialCapacity: number;
24
24
  get initialCapacity(): number;
25
- set initialCapacity(value: number);
26
- private _loadFactor;
25
+ protected _loadFactor: number;
27
26
  get loadFactor(): number;
28
- set loadFactor(value: number);
29
- private _capacityMultiplier;
27
+ protected _capacityMultiplier: number;
30
28
  get capacityMultiplier(): number;
31
- set capacityMultiplier(value: number);
32
- private _size;
29
+ protected _size: number;
33
30
  get size(): number;
34
- set size(value: number);
35
- private _table;
31
+ protected _table: Array<Array<[K, V]>>;
36
32
  get table(): Array<Array<[K, V]>>;
37
- set table(value: Array<Array<[K, V]>>);
38
- private _hashFn;
33
+ protected _hashFn: HashFunction<K>;
39
34
  get hashFn(): HashFunction<K>;
40
- set hashFn(value: HashFunction<K>);
41
35
  set(key: K, value: V): void;
42
36
  get(key: K): V | undefined;
43
37
  delete(key: K): void;
@@ -45,12 +39,12 @@ export declare class HashMap<K, V> {
45
39
  [Symbol.iterator](): IterableIterator<[K, V]>;
46
40
  clear(): void;
47
41
  isEmpty(): boolean;
48
- private _hash;
42
+ protected _hash(key: K): number;
49
43
  /**
50
44
  * The `resizeTable` function resizes the table used in a hash map by creating a new table with a specified capacity and
51
45
  * rehashing the key-value pairs from the old table into the new table.
52
46
  * @param {number} newCapacity - The newCapacity parameter is the desired capacity for the resized table. It represents
53
47
  * the number of buckets that the new table should have.
54
48
  */
55
- private resizeTable;
49
+ protected resizeTable(newCapacity: number): void;
56
50
  }
@@ -41,39 +41,21 @@ class HashMap {
41
41
  get initialCapacity() {
42
42
  return this._initialCapacity;
43
43
  }
44
- set initialCapacity(value) {
45
- this._initialCapacity = value;
46
- }
47
44
  get loadFactor() {
48
45
  return this._loadFactor;
49
46
  }
50
- set loadFactor(value) {
51
- this._loadFactor = value;
52
- }
53
47
  get capacityMultiplier() {
54
48
  return this._capacityMultiplier;
55
49
  }
56
- set capacityMultiplier(value) {
57
- this._capacityMultiplier = value;
58
- }
59
50
  get size() {
60
51
  return this._size;
61
52
  }
62
- set size(value) {
63
- this._size = value;
64
- }
65
53
  get table() {
66
54
  return this._table;
67
55
  }
68
- set table(value) {
69
- this._table = value;
70
- }
71
56
  get hashFn() {
72
57
  return this._hashFn;
73
58
  }
74
- set hashFn(value) {
75
- this._hashFn = value;
76
- }
77
59
  set(key, value) {
78
60
  const loadFactor = this.size / this.table.length;
79
61
  if (loadFactor >= this.loadFactor) {
@@ -91,7 +73,7 @@ class HashMap {
91
73
  }
92
74
  }
93
75
  this.table[index].push([key, value]);
94
- this.size++;
76
+ this._size++;
95
77
  }
96
78
  get(key) {
97
79
  const index = this._hash(key);
@@ -113,7 +95,7 @@ class HashMap {
113
95
  for (let i = 0; i < this.table[index].length; i++) {
114
96
  if (this.table[index][i][0] === key) {
115
97
  this.table[index].splice(i, 1);
116
- this.size--;
98
+ this._size--;
117
99
  // Check if the table needs to be resized down
118
100
  const loadFactor = this.size / this.table.length;
119
101
  if (loadFactor < this.loadFactor / this.capacityMultiplier) {
@@ -136,8 +118,8 @@ class HashMap {
136
118
  return this.entries();
137
119
  }
138
120
  clear() {
139
- this.size = 0;
140
- this.table = new Array(this.initialCapacity);
121
+ this._size = 0;
122
+ this._table = new Array(this.initialCapacity);
141
123
  }
142
124
  isEmpty() {
143
125
  return this.size === 0;
@@ -13,20 +13,17 @@ export declare class HashTableNode<K, V> {
13
13
  }
14
14
  import { HashFunction } from '../../types';
15
15
  export declare class HashTable<K, V> {
16
- private static readonly DEFAULT_CAPACITY;
17
- private static readonly LOAD_FACTOR;
16
+ protected static readonly DEFAULT_CAPACITY = 16;
17
+ protected static readonly LOAD_FACTOR = 0.75;
18
18
  constructor(capacity?: number, hashFn?: HashFunction<K>);
19
- private _capacity;
19
+ protected _capacity: number;
20
20
  get capacity(): number;
21
- set capacity(value: number);
22
- private _size;
21
+ protected _size: number;
23
22
  get size(): number;
24
- private _buckets;
23
+ protected _buckets: Array<HashTableNode<K, V> | null>;
25
24
  get buckets(): Array<HashTableNode<K, V> | null>;
26
- set buckets(value: Array<HashTableNode<K, V> | null>);
27
- private _hashFn;
25
+ protected _hashFn: HashFunction<K>;
28
26
  get hashFn(): HashFunction<K>;
29
- set hashFn(value: HashFunction<K>);
30
27
  /**
31
28
  * The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
32
29
  * @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
@@ -26,24 +26,15 @@ class HashTable {
26
26
  get capacity() {
27
27
  return this._capacity;
28
28
  }
29
- set capacity(value) {
30
- this._capacity = value;
31
- }
32
29
  get size() {
33
30
  return this._size;
34
31
  }
35
32
  get buckets() {
36
33
  return this._buckets;
37
34
  }
38
- set buckets(value) {
39
- this._buckets = value;
40
- }
41
35
  get hashFn() {
42
36
  return this._hashFn;
43
37
  }
44
- set hashFn(value) {
45
- this._hashFn = value;
46
- }
47
38
  /**
48
39
  * The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
49
40
  * @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
@@ -6,12 +6,14 @@
6
6
  */
7
7
  import type { Comparator, DFSOrderPattern } from '../../types';
8
8
  export declare class Heap<E = any> {
9
- protected nodes: E[];
10
- protected readonly comparator: Comparator<E>;
11
9
  constructor(options: {
12
10
  comparator: Comparator<E>;
13
11
  nodes?: E[];
14
12
  });
13
+ protected _nodes: E[];
14
+ get nodes(): E[];
15
+ protected _comparator: Comparator<E>;
16
+ get comparator(): Comparator<E>;
15
17
  /**
16
18
  * Get the size (number of elements) of the heap.
17
19
  */
@@ -123,11 +125,15 @@ export declare class FibonacciHeapNode<E> {
123
125
  constructor(element: E, degree?: number);
124
126
  }
125
127
  export declare class FibonacciHeap<E> {
126
- root?: FibonacciHeapNode<E>;
127
- size: number;
128
- protected min?: FibonacciHeapNode<E>;
129
- protected readonly comparator: Comparator<E>;
130
128
  constructor(comparator?: Comparator<E>);
129
+ protected _root?: FibonacciHeapNode<E>;
130
+ get root(): FibonacciHeapNode<E> | undefined;
131
+ protected _size: number;
132
+ get size(): number;
133
+ protected _min?: FibonacciHeapNode<E>;
134
+ get min(): FibonacciHeapNode<E> | undefined;
135
+ protected _comparator: Comparator<E>;
136
+ get comparator(): Comparator<E>;
131
137
  /**
132
138
  * Get the size (number of elements) of the heap.
133
139
  * @returns {number} The size of the heap. Returns 0 if the heap is empty. Returns -1 if the heap is invalid.
@@ -9,13 +9,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.FibonacciHeap = exports.FibonacciHeapNode = exports.Heap = void 0;
10
10
  class Heap {
11
11
  constructor(options) {
12
- this.nodes = [];
13
- this.comparator = options.comparator;
12
+ this._nodes = [];
13
+ this._comparator = options.comparator;
14
14
  if (options.nodes && options.nodes.length > 0) {
15
- this.nodes = options.nodes;
15
+ this._nodes = options.nodes;
16
16
  this.fix();
17
17
  }
18
18
  }
19
+ get nodes() {
20
+ return this._nodes;
21
+ }
22
+ get comparator() {
23
+ return this._comparator;
24
+ }
19
25
  /**
20
26
  * Get the size (number of elements) of the heap.
21
27
  */
@@ -98,14 +104,14 @@ class Heap {
98
104
  * Reset the nodes of the heap. Make the nodes empty.
99
105
  */
100
106
  clear() {
101
- this.nodes = [];
107
+ this._nodes = [];
102
108
  }
103
109
  /**
104
110
  * Clear and add nodes of the heap
105
111
  * @param nodes
106
112
  */
107
113
  refill(nodes) {
108
- this.nodes = nodes;
114
+ this._nodes = nodes;
109
115
  this.fix();
110
116
  }
111
117
  /**
@@ -162,7 +168,7 @@ class Heap {
162
168
  */
163
169
  clone() {
164
170
  const clonedHeap = new Heap({ comparator: this.comparator });
165
- clonedHeap.nodes = [...this.nodes];
171
+ clonedHeap._nodes = [...this.nodes];
166
172
  return clonedHeap;
167
173
  }
168
174
  /**
@@ -239,21 +245,33 @@ class FibonacciHeapNode {
239
245
  exports.FibonacciHeapNode = FibonacciHeapNode;
240
246
  class FibonacciHeap {
241
247
  constructor(comparator) {
242
- this.size = 0;
248
+ this._size = 0;
243
249
  this.clear();
244
- this.comparator = comparator || this.defaultComparator;
250
+ this._comparator = comparator || this.defaultComparator;
245
251
  if (typeof this.comparator !== 'function') {
246
252
  throw new Error('FibonacciHeap constructor: given comparator should be a function.');
247
253
  }
248
254
  }
255
+ get root() {
256
+ return this._root;
257
+ }
258
+ get size() {
259
+ return this._size;
260
+ }
261
+ get min() {
262
+ return this._min;
263
+ }
264
+ get comparator() {
265
+ return this._comparator;
266
+ }
249
267
  /**
250
268
  * Get the size (number of elements) of the heap.
251
269
  * @returns {number} The size of the heap. Returns 0 if the heap is empty. Returns -1 if the heap is invalid.
252
270
  */
253
271
  clear() {
254
- this.root = undefined;
255
- this.min = undefined;
256
- this.size = 0;
272
+ this._root = undefined;
273
+ this._min = undefined;
274
+ this._size = 0;
257
275
  }
258
276
  /**
259
277
  * O(1) time operation.
@@ -276,9 +294,9 @@ class FibonacciHeap {
276
294
  node.right = node;
277
295
  this.mergeWithRoot(node);
278
296
  if (!this.min || this.comparator(node.element, this.min.element) <= 0) {
279
- this.min = node;
297
+ this._min = node;
280
298
  }
281
- this.size++;
299
+ this._size++;
282
300
  return this;
283
301
  }
284
302
  /**
@@ -358,14 +376,14 @@ class FibonacciHeap {
358
376
  }
359
377
  this.removeFromRoot(z);
360
378
  if (z === z.right) {
361
- this.min = undefined;
362
- this.root = undefined;
379
+ this._min = undefined;
380
+ this._root = undefined;
363
381
  }
364
382
  else {
365
- this.min = z.right;
383
+ this._min = z.right;
366
384
  this.consolidate();
367
385
  }
368
- this.size--;
386
+ this._size--;
369
387
  return z.element;
370
388
  }
371
389
  /**
@@ -390,10 +408,10 @@ class FibonacciHeap {
390
408
  }
391
409
  // Update the minimum node
392
410
  if (!this.min || (heapToMerge.min && this.comparator(heapToMerge.min.element, this.min.element) < 0)) {
393
- this.min = heapToMerge.min;
411
+ this._min = heapToMerge.min;
394
412
  }
395
413
  // Update the size
396
- this.size += heapToMerge.size;
414
+ this._size += heapToMerge.size;
397
415
  // Clear the heap that was merged
398
416
  heapToMerge.clear();
399
417
  }
@@ -424,7 +442,7 @@ class FibonacciHeap {
424
442
  */
425
443
  mergeWithRoot(node) {
426
444
  if (!this.root) {
427
- this.root = node;
445
+ this._root = node;
428
446
  }
429
447
  else {
430
448
  node.right = this.root.right;
@@ -441,7 +459,7 @@ class FibonacciHeap {
441
459
  */
442
460
  removeFromRoot(node) {
443
461
  if (this.root === node)
444
- this.root = node.right;
462
+ this._root = node.right;
445
463
  if (node.left)
446
464
  node.left.right = node.right;
447
465
  if (node.right)
@@ -489,7 +507,7 @@ class FibonacciHeap {
489
507
  }
490
508
  for (let i = 0; i < this.size; i++) {
491
509
  if (A[i] && this.comparator(A[i].element, this.min.element) <= 0) {
492
- this.min = A[i];
510
+ this._min = A[i];
493
511
  }
494
512
  }
495
513
  }
@@ -6,34 +6,26 @@
6
6
  * @license MIT License
7
7
  */
8
8
  export declare class DoublyLinkedListNode<E = any> {
9
+ value: E;
10
+ next: DoublyLinkedListNode<E> | null;
11
+ prev: DoublyLinkedListNode<E> | null;
9
12
  /**
10
13
  * The constructor function initializes the value, next, and previous properties of an object.
11
14
  * @param {E} value - The "value" parameter is the value that will be stored in the node. It can be of any data type, as it
12
15
  * is defined as a generic type "E".
13
16
  */
14
17
  constructor(value: E);
15
- private _value;
16
- get value(): E;
17
- set value(value: E);
18
- private _next;
19
- get next(): DoublyLinkedListNode<E> | null;
20
- set next(value: DoublyLinkedListNode<E> | null);
21
- private _prev;
22
- get prev(): DoublyLinkedListNode<E> | null;
23
- set prev(value: DoublyLinkedListNode<E> | null);
24
18
  }
25
19
  export declare class DoublyLinkedList<E = any> {
26
20
  /**
27
21
  * The constructor initializes the linked list with an empty head, tail, and length.
28
22
  */
29
23
  constructor();
30
- private _head;
24
+ protected _head: DoublyLinkedListNode<E> | null;
31
25
  get head(): DoublyLinkedListNode<E> | null;
32
- set head(value: DoublyLinkedListNode<E> | null);
33
- private _tail;
26
+ protected _tail: DoublyLinkedListNode<E> | null;
34
27
  get tail(): DoublyLinkedListNode<E> | null;
35
- set tail(value: DoublyLinkedListNode<E> | null);
36
- private _length;
28
+ protected _length: number;
37
29
  get length(): number;
38
30
  get size(): number;
39
31
  /**