data-structure-typed 1.12.11 → 1.15.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 (81) hide show
  1. package/README.md +278 -179
  2. package/dist/data-structures/binary-tree/avl-tree.d.ts +14 -5
  3. package/dist/data-structures/binary-tree/avl-tree.js +15 -6
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +11 -2
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +11 -2
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +72 -18
  7. package/dist/data-structures/binary-tree/binary-tree.js +139 -62
  8. package/dist/data-structures/binary-tree/bst.d.ts +92 -5
  9. package/dist/data-structures/binary-tree/bst.js +89 -5
  10. package/dist/data-structures/binary-tree/segment-tree.d.ts +70 -2
  11. package/dist/data-structures/binary-tree/segment-tree.js +86 -2
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +34 -3
  13. package/dist/data-structures/binary-tree/tree-multiset.js +35 -4
  14. package/dist/data-structures/graph/abstract-graph.d.ts +45 -5
  15. package/dist/data-structures/graph/abstract-graph.js +59 -11
  16. package/dist/data-structures/graph/directed-graph.d.ts +26 -4
  17. package/dist/data-structures/graph/directed-graph.js +38 -39
  18. package/dist/data-structures/graph/undirected-graph.d.ts +23 -0
  19. package/dist/data-structures/graph/undirected-graph.js +41 -3
  20. package/dist/data-structures/hash/coordinate-map.d.ts +12 -3
  21. package/dist/data-structures/hash/coordinate-map.js +21 -2
  22. package/dist/data-structures/hash/coordinate-set.d.ts +12 -3
  23. package/dist/data-structures/hash/coordinate-set.js +21 -2
  24. package/dist/data-structures/heap/heap.d.ts +25 -6
  25. package/dist/data-structures/heap/heap.js +46 -8
  26. package/dist/data-structures/heap/max-heap.d.ts +5 -2
  27. package/dist/data-structures/heap/max-heap.js +5 -2
  28. package/dist/data-structures/heap/min-heap.d.ts +5 -2
  29. package/dist/data-structures/heap/min-heap.js +5 -2
  30. package/dist/data-structures/index.d.ts +1 -0
  31. package/dist/data-structures/index.js +1 -0
  32. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +32 -9
  33. package/dist/data-structures/linked-list/doubly-linked-list.js +75 -8
  34. package/dist/data-structures/linked-list/singly-linked-list.d.ts +267 -330
  35. package/dist/data-structures/linked-list/singly-linked-list.js +263 -275
  36. package/dist/data-structures/matrix/matrix.d.ts +5 -2
  37. package/dist/data-structures/matrix/matrix.js +5 -2
  38. package/dist/data-structures/matrix/matrix2d.d.ts +5 -2
  39. package/dist/data-structures/matrix/matrix2d.js +5 -2
  40. package/dist/data-structures/matrix/navigator.d.ts +5 -2
  41. package/dist/data-structures/matrix/vector2d.d.ts +5 -2
  42. package/dist/data-structures/matrix/vector2d.js +5 -2
  43. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +5 -2
  44. package/dist/data-structures/priority-queue/max-priority-queue.js +5 -2
  45. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +5 -2
  46. package/dist/data-structures/priority-queue/min-priority-queue.js +5 -2
  47. package/dist/data-structures/priority-queue/priority-queue.d.ts +14 -5
  48. package/dist/data-structures/priority-queue/priority-queue.js +20 -4
  49. package/dist/data-structures/queue/deque.d.ts +30 -16
  50. package/dist/data-structures/queue/deque.js +62 -12
  51. package/dist/data-structures/queue/queue.d.ts +4 -4
  52. package/dist/data-structures/queue/queue.js +4 -4
  53. package/dist/data-structures/stack/stack.d.ts +1 -1
  54. package/dist/data-structures/stack/stack.js +1 -1
  55. package/dist/data-structures/trie/trie.d.ts +6 -3
  56. package/dist/data-structures/trie/trie.js +7 -4
  57. package/dist/data-structures/types/abstract-graph.d.ts +2 -2
  58. package/dist/utils/index.d.ts +1 -0
  59. package/dist/utils/index.js +1 -0
  60. package/dist/utils/types/utils.d.ts +8 -10
  61. package/dist/utils/types/utils.js +0 -1
  62. package/dist/utils/utils.d.ts +18 -8
  63. package/dist/utils/utils.js +93 -47
  64. package/package.json +2 -2
  65. package/src/data-structures/binary-tree/aa-tree.ts +1 -1
  66. package/src/data-structures/binary-tree/binary-tree.ts +84 -14
  67. package/src/data-structures/binary-tree/segment-tree.ts +45 -13
  68. package/src/data-structures/graph/abstract-graph.ts +58 -15
  69. package/src/data-structures/graph/directed-graph.ts +14 -5
  70. package/src/data-structures/graph/undirected-graph.ts +23 -6
  71. package/src/data-structures/hash/coordinate-map.ts +13 -1
  72. package/src/data-structures/hash/coordinate-set.ts +13 -1
  73. package/src/data-structures/heap/heap.ts +31 -0
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +68 -11
  75. package/src/data-structures/linked-list/singly-linked-list.ts +312 -334
  76. package/src/data-structures/priority-queue/priority-queue.ts +15 -2
  77. package/src/data-structures/queue/deque.ts +38 -8
  78. package/src/data-structures/types/abstract-graph.ts +3 -3
  79. package/tests/unit/data-structures/graph/directed-graph.test.ts +431 -8
  80. package/dist/utils/trampoline.d.ts +0 -14
  81. package/dist/utils/trampoline.js +0 -130
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  export declare class MatrixNTI2D<T = number> {
6
9
  private readonly _matrix;
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatrixNTI2D = void 0;
4
4
  /**
5
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
7
10
  */
8
11
  // todo need to be improved
9
12
  var MatrixNTI2D = /** @class */ (function () {
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import Vector2D from './vector2d';
6
9
  export declare class Matrix2D {
@@ -5,8 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Matrix2D = void 0;
7
7
  /**
8
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
9
- * @license MIT
8
+ * data-structure-typed
9
+ *
10
+ * @author Tyler Zeng
11
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
12
+ * @license MIT License
10
13
  */
11
14
  var vector2d_1 = __importDefault(require("./vector2d"));
12
15
  var Matrix2D = /** @class */ (function () {
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import type { Direction, NavigatorParams, Turning } from '../types';
6
9
  export declare class Character {
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  export declare class Vector2D {
6
9
  x: number;
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Vector2D = void 0;
4
4
  /**
5
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
7
10
  */
8
11
  var Vector2D = /** @class */ (function () {
9
12
  function Vector2D(x, y, w // needed for matrix multiplication
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import { PriorityQueue } from './priority-queue';
6
9
  import type { PriorityQueueOptions } from '../types';
@@ -17,8 +17,11 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.MaxPriorityQueue = void 0;
19
19
  /**
20
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
21
- * @license MIT
20
+ * data-structure-typed
21
+ *
22
+ * @author Tyler Zeng
23
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
24
+ * @license MIT License
22
25
  */
23
26
  var priority_queue_1 = require("./priority-queue");
24
27
  var MaxPriorityQueue = /** @class */ (function (_super) {
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import { PriorityQueue } from './priority-queue';
6
9
  import type { PriorityQueueOptions } from '../types';
@@ -17,8 +17,11 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.MinPriorityQueue = void 0;
19
19
  /**
20
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
21
- * @license MIT
20
+ * data-structure-typed
21
+ *
22
+ * @author Tyler Zeng
23
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
24
+ * @license MIT License
22
25
  */
23
26
  var priority_queue_1 = require("./priority-queue");
24
27
  var MinPriorityQueue = /** @class */ (function (_super) {
@@ -1,10 +1,19 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../types';
6
9
  export declare class PriorityQueue<T = number> {
7
- protected nodes: T[];
10
+ protected _nodes: T[];
11
+ get nodes(): T[];
12
+ /**
13
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
14
+ */
15
+ getNodes(): T[];
16
+ protected set nodes(value: T[]);
8
17
  /**
9
18
  * The constructor initializes a priority queue with the given options, including an array of nodes and a comparator
10
19
  * function.
@@ -29,11 +38,11 @@ export declare class PriorityQueue<T = number> {
29
38
  */
30
39
  static isPriorityQueueified<T>(options: Omit<PriorityQueueOptions<T>, 'isFix'>): boolean;
31
40
  /**
32
- * The "offer" function adds a node to the heap and ensures that the heap property is maintained.
41
+ * The "add" function adds a node to the heap and ensures that the heap property is maintained.
33
42
  * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
34
43
  * that needs to be added to the heap.
35
44
  */
36
- offer(node: T): void;
45
+ add(node: T): void;
37
46
  /**
38
47
  * The `peek` function returns the first element of the `nodes` array if it exists, otherwise it returns `null`.
39
48
  * @returns The `peek()` function is returning the first element (`T`) of the `nodes` array if the `size` is not zero.
@@ -44,7 +44,7 @@ var PriorityQueue = /** @class */ (function () {
44
44
  * @param options - The `options` parameter is an object that contains the following properties:
45
45
  */
46
46
  function PriorityQueue(options) {
47
- this.nodes = [];
47
+ this._nodes = [];
48
48
  this._comparator = function (a, b) {
49
49
  var aKey = a, bKey = b;
50
50
  return aKey - bKey;
@@ -53,10 +53,26 @@ var PriorityQueue = /** @class */ (function () {
53
53
  this._comparator = comparator;
54
54
  if (nodes && nodes instanceof Array && nodes.length > 0) {
55
55
  // TODO support distinct
56
- this.nodes = Array.isArray(nodes) ? __spreadArray([], __read(nodes), false) : [];
56
+ this._nodes = Array.isArray(nodes) ? __spreadArray([], __read(nodes), false) : [];
57
57
  isFix && this._fix();
58
58
  }
59
59
  }
60
+ Object.defineProperty(PriorityQueue.prototype, "nodes", {
61
+ get: function () {
62
+ return this._nodes;
63
+ },
64
+ set: function (value) {
65
+ this._nodes = value;
66
+ },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ /**
71
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
72
+ */
73
+ PriorityQueue.prototype.getNodes = function () {
74
+ return this._nodes;
75
+ };
60
76
  Object.defineProperty(PriorityQueue.prototype, "size", {
61
77
  get: function () {
62
78
  return this.nodes.length;
@@ -87,11 +103,11 @@ var PriorityQueue = /** @class */ (function () {
87
103
  return new PriorityQueue(__assign(__assign({}, options), { isFix: true })).isValid();
88
104
  };
89
105
  /**
90
- * The "offer" function adds a node to the heap and ensures that the heap property is maintained.
106
+ * The "add" function adds a node to the heap and ensures that the heap property is maintained.
91
107
  * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
92
108
  * that needs to be added to the heap.
93
109
  */
94
- PriorityQueue.prototype.offer = function (node) {
110
+ PriorityQueue.prototype.add = function (node) {
95
111
  this.nodes.push(node);
96
112
  this._heapifyUp(this.size - 1);
97
113
  };
@@ -1,22 +1,36 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import { DoublyLinkedList } from '../linked-list';
6
9
  export declare class Deque<T> extends DoublyLinkedList<T> {
7
10
  }
8
11
  export declare class ObjectDeque<T> {
9
- protected _nodes: {
10
- [key: number]: T;
12
+ private _nodes;
13
+ get nodes(): {
14
+ [p: number]: T;
11
15
  };
12
- protected _capacity: number;
13
- protected _first: number;
14
- protected _last: number;
15
- protected _size: number;
16
+ protected set nodes(value: {
17
+ [p: number]: T;
18
+ });
19
+ private _capacity;
20
+ get capacity(): number;
21
+ set capacity(value: number);
22
+ private _first;
23
+ get first(): number;
24
+ set first(value: number);
25
+ private _last;
26
+ get last(): number;
27
+ set last(value: number);
28
+ private _size;
29
+ get size(): number;
30
+ protected set size(value: number);
16
31
  constructor(capacity?: number);
17
- size(): number;
18
- offerFirst(value: T): void;
19
- offerLast(value: T): void;
32
+ addFirst(value: T): void;
33
+ addLast(value: T): void;
20
34
  pollFirst(): T | undefined;
21
35
  peekFirst(): T | undefined;
22
36
  pollLast(): T | undefined;
@@ -28,11 +42,11 @@ export declare class ArrayDeque<T> {
28
42
  protected _nodes: T[];
29
43
  get size(): number;
30
44
  /**
31
- * The function "offerLast" adds a value to the end of an array.
45
+ * The function "addLast" adds a value to the end of an array.
32
46
  * @param {T} value - The value parameter represents the value that you want to add to the end of the array.
33
47
  * @returns The return value is the new length of the array after the value has been added.
34
48
  */
35
- offerLast(value: T): number;
49
+ addLast(value: T): number;
36
50
  /**
37
51
  * The function "pollLast" returns and removes the last element from an array, or returns null if the array is empty.
38
52
  * @returns The method `pollLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
@@ -45,12 +59,12 @@ export declare class ArrayDeque<T> {
45
59
  */
46
60
  pollFirst(): T | null;
47
61
  /**
48
- * The function "offerFirst" adds a value to the beginning of an array.
62
+ * The function "addFirst" adds a value to the beginning of an array.
49
63
  * @param {T} value - The value parameter represents the value that you want to add to the beginning of the array.
50
- * @returns The return value of the `offerFirst` function is the new length of the array `_nodes` after adding the
64
+ * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
51
65
  * `value` at the beginning.
52
66
  */
53
- offerFirst(value: T): number;
67
+ addFirst(value: T): number;
54
68
  /**
55
69
  * The `peekFirst` function returns the first element of an array or null if the array is empty.
56
70
  * @returns The function `peekFirst()` is returning the first element (`T`) of the `_nodes` array. If the array is
@@ -17,8 +17,11 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.ArrayDeque = exports.ObjectDeque = exports.Deque = void 0;
19
19
  /**
20
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
21
- * @license MIT
20
+ * data-structure-typed
21
+ *
22
+ * @author Tyler Zeng
23
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
24
+ * @license MIT License
22
25
  */
23
26
  var linked_list_1 = require("../linked-list");
24
27
  // O(n) time complexity of obtaining the value
@@ -44,10 +47,57 @@ var ObjectDeque = /** @class */ (function () {
44
47
  if (capacity !== undefined)
45
48
  this._capacity = capacity;
46
49
  }
47
- ObjectDeque.prototype.size = function () {
48
- return this._size;
49
- };
50
- ObjectDeque.prototype.offerFirst = function (value) {
50
+ Object.defineProperty(ObjectDeque.prototype, "nodes", {
51
+ get: function () {
52
+ return this._nodes;
53
+ },
54
+ set: function (value) {
55
+ this._nodes = value;
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ Object.defineProperty(ObjectDeque.prototype, "capacity", {
61
+ get: function () {
62
+ return this._capacity;
63
+ },
64
+ set: function (value) {
65
+ this._capacity = value;
66
+ },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ Object.defineProperty(ObjectDeque.prototype, "first", {
71
+ get: function () {
72
+ return this._first;
73
+ },
74
+ set: function (value) {
75
+ this._first = value;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ Object.defineProperty(ObjectDeque.prototype, "last", {
81
+ get: function () {
82
+ return this._last;
83
+ },
84
+ set: function (value) {
85
+ this._last = value;
86
+ },
87
+ enumerable: false,
88
+ configurable: true
89
+ });
90
+ Object.defineProperty(ObjectDeque.prototype, "size", {
91
+ get: function () {
92
+ return this._size;
93
+ },
94
+ set: function (value) {
95
+ this._size = value;
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ ObjectDeque.prototype.addFirst = function (value) {
51
101
  if (this._size === 0) {
52
102
  var mid = Math.floor(this._capacity / 2);
53
103
  this._first = mid;
@@ -59,7 +109,7 @@ var ObjectDeque = /** @class */ (function () {
59
109
  this._nodes[this._first] = value;
60
110
  this._size++;
61
111
  };
62
- ObjectDeque.prototype.offerLast = function (value) {
112
+ ObjectDeque.prototype.addLast = function (value) {
63
113
  if (this._size === 0) {
64
114
  var mid = Math.floor(this._capacity / 2);
65
115
  this._first = mid;
@@ -120,11 +170,11 @@ var ArrayDeque = /** @class */ (function () {
120
170
  configurable: true
121
171
  });
122
172
  /**
123
- * The function "offerLast" adds a value to the end of an array.
173
+ * The function "addLast" adds a value to the end of an array.
124
174
  * @param {T} value - The value parameter represents the value that you want to add to the end of the array.
125
175
  * @returns The return value is the new length of the array after the value has been added.
126
176
  */
127
- ArrayDeque.prototype.offerLast = function (value) {
177
+ ArrayDeque.prototype.addLast = function (value) {
128
178
  return this._nodes.push(value);
129
179
  };
130
180
  /**
@@ -145,12 +195,12 @@ var ArrayDeque = /** @class */ (function () {
145
195
  return (_a = this._nodes.shift()) !== null && _a !== void 0 ? _a : null;
146
196
  };
147
197
  /**
148
- * The function "offerFirst" adds a value to the beginning of an array.
198
+ * The function "addFirst" adds a value to the beginning of an array.
149
199
  * @param {T} value - The value parameter represents the value that you want to add to the beginning of the array.
150
- * @returns The return value of the `offerFirst` function is the new length of the array `_nodes` after adding the
200
+ * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
151
201
  * `value` at the beginning.
152
202
  */
153
- ArrayDeque.prototype.offerFirst = function (value) {
203
+ ArrayDeque.prototype.addFirst = function (value) {
154
204
  return this._nodes.unshift(value);
155
205
  };
156
206
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license MIT
3
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
4
4
  * @class
5
5
  */
6
6
  export declare class Queue<T> {
@@ -23,11 +23,11 @@ export declare class Queue<T> {
23
23
  */
24
24
  static fromArray<T>(elements: T[]): Queue<T>;
25
25
  /**
26
- * The offer function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
26
+ * The add function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
27
27
  * @param {T} element - The `element` parameter represents the element that you want to add to the queue.
28
- * @returns The `offer` method is returning a `Queue<T>` object.
28
+ * @returns The `add` method is returning a `Queue<T>` object.
29
29
  */
30
- offer(element: T): Queue<T>;
30
+ add(element: T): Queue<T>;
31
31
  /**
32
32
  * The `poll` function removes and returns the first element in the queue, and adjusts the internal data structure if
33
33
  * necessary to optimize performance.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Queue = void 0;
4
4
  /**
5
5
  * @license MIT
6
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
6
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
7
7
  * @class
8
8
  */
9
9
  var Queue = /** @class */ (function () {
@@ -29,11 +29,11 @@ var Queue = /** @class */ (function () {
29
29
  return new Queue(elements);
30
30
  };
31
31
  /**
32
- * The offer function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
32
+ * The add function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
33
33
  * @param {T} element - The `element` parameter represents the element that you want to add to the queue.
34
- * @returns The `offer` method is returning a `Queue<T>` object.
34
+ * @returns The `add` method is returning a `Queue<T>` object.
35
35
  */
36
- Queue.prototype.offer = function (element) {
36
+ Queue.prototype.add = function (element) {
37
37
  this._nodes.push(element);
38
38
  return this;
39
39
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license MIT
3
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
4
4
  * @class
5
5
  */
6
6
  export declare class Stack<T> {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Stack = void 0;
4
4
  /**
5
5
  * @license MIT
6
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
6
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
7
7
  * @class
8
8
  */
9
9
  var Stack = /** @class */ (function () {
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  export declare class TrieNode {
6
9
  protected _value: string;
@@ -19,7 +22,7 @@ export declare class Trie {
19
22
  protected _root: TrieNode;
20
23
  get root(): TrieNode;
21
24
  set root(v: TrieNode);
22
- put(word: string): boolean;
25
+ add(word: string): boolean;
23
26
  has(input: string): boolean;
24
27
  remove(word: string): boolean;
25
28
  /**
@@ -13,8 +13,11 @@ var __values = (this && this.__values) || function(o) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.Trie = exports.TrieNode = void 0;
15
15
  /**
16
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
17
- * @license MIT
16
+ * data-structure-typed
17
+ *
18
+ * @author Tyler Zeng
19
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
20
+ * @license MIT License
18
21
  */
19
22
  var TrieNode = /** @class */ (function () {
20
23
  function TrieNode(v) {
@@ -63,7 +66,7 @@ var Trie = /** @class */ (function () {
63
66
  try {
64
67
  for (var words_1 = __values(words), words_1_1 = words_1.next(); !words_1_1.done; words_1_1 = words_1.next()) {
65
68
  var i = words_1_1.value;
66
- this.put(i);
69
+ this.add(i);
67
70
  }
68
71
  }
69
72
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -85,7 +88,7 @@ var Trie = /** @class */ (function () {
85
88
  enumerable: false,
86
89
  configurable: true
87
90
  });
88
- Trie.prototype.put = function (word) {
91
+ Trie.prototype.add = function (word) {
89
92
  var e_2, _a;
90
93
  var cur = this._root;
91
94
  try {
@@ -8,7 +8,7 @@ export type DijkstraResult<V> = {
8
8
  minPath: V[];
9
9
  } | null;
10
10
  export interface IGraph<V, E> {
11
- containsVertex(vertexOrId: V | VertexId): boolean;
11
+ hasVertex(vertexOrId: V | VertexId): boolean;
12
12
  getVertex(vertexOrId: VertexId | V): V | null;
13
13
  getVertexId(vertexOrId: V | VertexId): VertexId;
14
14
  vertexSet(): Map<VertexId, V>;
@@ -17,7 +17,7 @@ export interface IGraph<V, E> {
17
17
  removeAllVertices(vertices: V[] | VertexId[]): boolean;
18
18
  degreeOf(vertexOrId: V | VertexId): number;
19
19
  edgesOf(vertexOrId: V | VertexId): E[];
20
- containsEdge(src: V | VertexId, dest: V | VertexId): boolean;
20
+ hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
21
21
  getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
22
22
  edgeSet(): E[];
23
23
  addEdge(edge: E): boolean;
@@ -1 +1,2 @@
1
1
  export * from './utils';
2
+ export * from './types';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./utils"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -1,3 +1,10 @@
1
+ export type JSONSerializable = {
2
+ [key: string]: any;
3
+ };
4
+ export type JSONValue = string | number | boolean | undefined | JSONObject;
5
+ export interface JSONObject {
6
+ [key: string]: JSONValue;
7
+ }
1
8
  export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
2
9
  export type Primitive = number | string | boolean | symbol | undefined | null | void | AnyFunction | Date;
3
10
  export type Cast<T, TComplex> = {
@@ -6,13 +13,6 @@ export type Cast<T, TComplex> = {
6
13
  export type DeepLeavesWrap<T, TComplex> = T extends string ? Cast<string, TComplex> : T extends number ? Cast<number, TComplex> : T extends boolean ? Cast<boolean, TComplex> : T extends undefined ? Cast<undefined, TComplex> : T extends null ? Cast<null, TComplex> : T extends void ? Cast<void, TComplex> : T extends symbol ? Cast<symbol, TComplex> : T extends AnyFunction ? Cast<AnyFunction, TComplex> : T extends Date ? Cast<Date, TComplex> : {
7
14
  [K in keyof T]: T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[] : DeepLeavesWrap<T[K], TComplex>;
8
15
  };
9
- export type JSONSerializable = {
10
- [key: string]: any;
11
- };
12
- export type JSONValue = string | number | boolean | undefined | JSONObject;
13
- export interface JSONObject {
14
- [key: string]: JSONValue;
15
- }
16
16
  export type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : T extends AnyFunction ? 'function' : 'object';
17
17
  export type JsonKeys<T> = keyof {
18
18
  [P in keyof T]: number;
@@ -51,10 +51,8 @@ export type DeepProxyOnChange = (target: any, property: string | symbol, value:
51
51
  export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
52
52
  export type CurryFunc<T> = T extends (...args: infer Args) => infer R ? Args extends [infer Arg, ...infer RestArgs] ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R> : R : T;
53
53
  export type ToThunkFn = () => ReturnType<TrlFn>;
54
- declare const THUNK_SYMBOL: unique symbol;
55
54
  export type Thunk = () => ReturnType<ToThunkFn> & {
56
- __THUNK__: typeof THUNK_SYMBOL;
55
+ __THUNK__: Symbol;
57
56
  };
58
57
  export type TrlFn = (...args: any[]) => any;
59
58
  export type TrlAsyncFn = (...args: any[]) => any;
60
- export {};
@@ -52,4 +52,3 @@ var TreeNode = /** @class */ (function () {
52
52
  return TreeNode;
53
53
  }());
54
54
  exports.TreeNode = TreeNode;
55
- var THUNK_SYMBOL = Symbol('thunk');