directed-graph-typed 1.46.2 → 1.46.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/data-structures/hash/hash-map.d.ts +31 -116
  2. package/dist/data-structures/hash/hash-map.js +126 -254
  3. package/dist/data-structures/hash/index.d.ts +0 -4
  4. package/dist/data-structures/hash/index.js +0 -4
  5. package/dist/data-structures/queue/deque.d.ts +6 -74
  6. package/dist/data-structures/queue/deque.js +20 -142
  7. package/dist/types/data-structures/hash/hash-map.d.ts +5 -0
  8. package/dist/types/data-structures/hash/index.d.ts +0 -4
  9. package/dist/types/data-structures/hash/index.js +0 -4
  10. package/dist/utils/utils.d.ts +1 -1
  11. package/dist/utils/utils.js +3 -3
  12. package/package.json +2 -2
  13. package/src/data-structures/hash/hash-map.ts +153 -275
  14. package/src/data-structures/hash/index.ts +0 -4
  15. package/src/data-structures/queue/deque.ts +22 -161
  16. package/src/types/data-structures/hash/hash-map.ts +6 -0
  17. package/src/types/data-structures/hash/index.ts +0 -4
  18. package/src/utils/utils.ts +1 -1
  19. package/dist/data-structures/hash/coordinate-map.d.ts +0 -44
  20. package/dist/data-structures/hash/coordinate-map.js +0 -62
  21. package/dist/data-structures/hash/coordinate-set.d.ts +0 -36
  22. package/dist/data-structures/hash/coordinate-set.js +0 -52
  23. package/dist/data-structures/hash/tree-map.d.ts +0 -2
  24. package/dist/data-structures/hash/tree-map.js +0 -6
  25. package/dist/data-structures/hash/tree-set.d.ts +0 -2
  26. package/dist/data-structures/hash/tree-set.js +0 -6
  27. package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -1
  28. package/dist/types/data-structures/hash/coordinate-map.js +0 -2
  29. package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -1
  30. package/dist/types/data-structures/hash/coordinate-set.js +0 -2
  31. package/dist/types/data-structures/hash/tree-map.d.ts +0 -1
  32. package/dist/types/data-structures/hash/tree-map.js +0 -2
  33. package/dist/types/data-structures/hash/tree-set.d.ts +0 -1
  34. package/dist/types/data-structures/hash/tree-set.js +0 -2
  35. package/src/data-structures/hash/coordinate-map.ts +0 -63
  36. package/src/data-structures/hash/coordinate-set.ts +0 -52
  37. package/src/data-structures/hash/tree-map.ts +0 -2
  38. package/src/data-structures/hash/tree-set.ts +0 -2
  39. package/src/types/data-structures/hash/coordinate-map.ts +0 -1
  40. package/src/types/data-structures/hash/coordinate-set.ts +0 -1
  41. package/src/types/data-structures/hash/tree-map.ts +0 -1
  42. package/src/types/data-structures/hash/tree-set.ts +0 -1
@@ -7,8 +7,8 @@
7
7
  */
8
8
 
9
9
 
10
- import { IterableWithSizeOrLength, IterateDirection } from "../../types";
11
- import { calcMinUnitsRequired, rangeCheck, throwRangeError } from "../../utils";
10
+ import { IterableWithSizeOrLength } from "../../types";
11
+ import { calcMinUnitsRequired, rangeCheck } from "../../utils";
12
12
 
13
13
  /**
14
14
  * Deque can provide random access with O(1) time complexity
@@ -17,89 +17,6 @@ import { calcMinUnitsRequired, rangeCheck, throwRangeError } from "../../utils";
17
17
  * Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
18
18
  */
19
19
 
20
- export class DequeIterator<E> {
21
- iterateDirection: IterateDirection;
22
-
23
- index: number;
24
- readonly deque: Deque<E>;
25
-
26
- /**
27
- * The constructor initializes the index, iterate direction, and prev/next functions for a
28
- * DequeIterator object.
29
- * @param {number} index - The index parameter represents the current index position of the iterator
30
- * within the deque. It is a number that indicates the position of the element that the iterator is
31
- * currently pointing to.
32
- * @param deque - The `deque` parameter is an instance of the `Deque` class. It represents a
33
- * double-ended queue data structure, which allows elements to be added or removed from both ends.
34
- * @param iterateDirection - The `iterateDirection` parameter is an optional parameter that specifies
35
- * the direction in which the iterator should iterate over the elements of the `deque`. It has a
36
- * default value of `IterateDirection.DEFAULT`.
37
- * @returns The constructor is not returning anything. It is used to initialize the properties of the
38
- * object being created.
39
- */
40
- constructor(index: number, deque: Deque<E>, iterateDirection = IterateDirection.DEFAULT) {
41
- this.index = index;
42
- this.iterateDirection = iterateDirection;
43
- if (this.iterateDirection === IterateDirection.DEFAULT) {
44
- this.prev = function () {
45
- if (this.index === 0) {
46
- throwRangeError();
47
- }
48
- this.index -= 1;
49
- return this;
50
- };
51
- this.next = function () {
52
- if (this.index === this.deque.size) {
53
- throwRangeError();
54
- }
55
- this.index += 1;
56
- return this;
57
- };
58
- } else {
59
- this.prev = function () {
60
- if (this.index === this.deque.size - 1) {
61
- throwRangeError();
62
- }
63
- this.index += 1;
64
- return this;
65
- };
66
- this.next = function () {
67
- if (this.index === -1) {
68
- throwRangeError();
69
- }
70
- this.index -= 1;
71
- return this;
72
- };
73
- }
74
- this.deque = deque;
75
- }
76
-
77
- get current() {
78
- return this.deque.getAt(this.index);
79
- }
80
-
81
- set current(newElement: E) {
82
- this.deque.setAt(this.index, newElement);
83
- }
84
-
85
- isAccessible() {
86
- return this.index !== this.deque.size;
87
- }
88
-
89
- prev(): DequeIterator<E> {
90
- return this;
91
- }
92
-
93
- next(): DequeIterator<E> {
94
- return this;
95
- }
96
-
97
- clone() {
98
- return new DequeIterator<E>(this.index, this.deque, this.iterateDirection);
99
- }
100
-
101
- }
102
-
103
20
  export class Deque<E> {
104
21
  protected _bucketFirst = 0;
105
22
  protected _firstInBucket = 0;
@@ -123,7 +40,7 @@ export class Deque<E> {
123
40
  if ('length' in elements) {
124
41
  if (elements.length instanceof Function) _size = elements.length(); else _size = elements.length;
125
42
  } else {
126
- if (elements.size instanceof Function) _size = elements.size();else _size = elements.size;
43
+ if (elements.size instanceof Function) _size = elements.size(); else _size = elements.size;
127
44
  }
128
45
 
129
46
  this._bucketSize = bucketSize;
@@ -245,38 +162,26 @@ export class Deque<E> {
245
162
  }
246
163
 
247
164
  /**
248
- * The `begin()` function returns a new iterator for a deque starting from the first element.
249
- * @returns A new instance of the DequeIterator class is being returned.
250
- */
251
- begin() {
252
- return new DequeIterator<E>(0, this);
253
- }
254
-
255
- /**
256
- * The `end()` function returns a new `DequeIterator` object with the size and reference to the
257
- * current deque.
258
- * @returns A new instance of the DequeIterator class is being returned.
165
+ * The below function is a generator that yields elements from a collection one by one.
259
166
  */
260
- end() {
261
- return new DequeIterator<E>(this.size, this);
262
- }
263
-
264
- /**
265
- * The reverseBegin function returns a new DequeIterator object that starts at the last element of
266
- * the deque and iterates in reverse direction.
267
- * @returns A new instance of the DequeIterator class is being returned.
268
- */
269
- reverseBegin() {
270
- return new DequeIterator<E>(this.size - 1, this, IterateDirection.REVERSE);
167
+ * begin(): Generator<E> {
168
+ let index = 0;
169
+ while (index < this.size) {
170
+ yield this.getAt(index);
171
+ index++;
172
+ }
271
173
  }
272
174
 
273
175
  /**
274
- * The reverseEnd() function returns a new DequeIterator object that iterates over the elements of a
275
- * Deque in reverse order.
276
- * @returns A new instance of the DequeIterator class is being returned.
176
+ * The function `reverseBegin()` is a generator that yields elements in reverse order starting from
177
+ * the last element.
277
178
  */
278
- reverseEnd() {
279
- return new DequeIterator<E>(-1, this, IterateDirection.REVERSE);
179
+ * reverseBegin(): Generator<E> {
180
+ let index = this.size - 1;
181
+ while (index >= 0) {
182
+ yield this.getAt(index);
183
+ index--;
184
+ }
280
185
  }
281
186
 
282
187
  /**
@@ -431,7 +336,7 @@ export class Deque<E> {
431
336
  * @returns The element at the specified position in the data structure is being returned.
432
337
  */
433
338
  getAt(pos: number): E {
434
- rangeCheck!(pos, 0, this.size - 1);
339
+ rangeCheck(pos, 0, this.size - 1);
435
340
  const {
436
341
  bucketIndex,
437
342
  indexInBucket
@@ -456,7 +361,7 @@ export class Deque<E> {
456
361
  * position in the data structure.
457
362
  */
458
363
  setAt(pos: number, element: E) {
459
- rangeCheck!(pos, 0, this.size - 1);
364
+ rangeCheck(pos, 0, this.size - 1);
460
365
  const {
461
366
  bucketIndex,
462
367
  indexInBucket
@@ -486,7 +391,7 @@ export class Deque<E> {
486
391
  */
487
392
  insertAt(pos: number, element: E, num = 1) {
488
393
  const length = this.size;
489
- rangeCheck!(pos, 0, length);
394
+ rangeCheck(pos, 0, length);
490
395
  if (pos === 0) {
491
396
  while (num--) this.unshift(element);
492
397
  } else if (pos === this.size) {
@@ -550,7 +455,7 @@ export class Deque<E> {
550
455
  * @returns The size of the data structure after the deletion operation is performed.
551
456
  */
552
457
  deleteAt(pos: number) {
553
- rangeCheck!(pos, 0, this.size - 1);
458
+ rangeCheck(pos, 0, this.size - 1);
554
459
  if (pos === 0) this.shift();
555
460
  else if (pos === this.size - 1) this.pop();
556
461
  else {
@@ -605,50 +510,6 @@ export class Deque<E> {
605
510
  return this.size;
606
511
  }
607
512
 
608
- /**
609
- * Time Complexity: O(n)
610
- * Space Complexity: O(1)
611
- */
612
-
613
- /**
614
- * Time Complexity: O(n)
615
- * Space Complexity: O(1)
616
- *
617
- * The function deletes an element from a deque using an iterator and returns the next iterator.
618
- * @param iter - The parameter `iter` is of type `DequeIterator<E>`. It represents an iterator object
619
- * that is used to iterate over elements in a deque (double-ended queue).
620
- * @returns the updated iterator after deleting an element from the deque.
621
- */
622
- deleteByIterator(iter: DequeIterator<E>) {
623
- const index = iter.index;
624
- this.deleteAt(index);
625
- iter = iter.next();
626
- return iter;
627
- }
628
-
629
- /**
630
- * Time Complexity: O(n)
631
- * Space Complexity: O(1)
632
- */
633
-
634
- /**
635
- * Time Complexity: O(n)
636
- * Space Complexity: O(1)
637
- *
638
- * The function `findIterator` searches for an element in a deque and returns an iterator pointing to
639
- * the element if found, otherwise it returns an iterator pointing to the end of the deque.
640
- * @param {E} element - The `element` parameter is the element that you want to find in the deque.
641
- * @returns The method `findIterator(element: E)` returns a `DequeIterator<E>` object.
642
- */
643
- findIterator(element: E) {
644
- for (let i = 0; i < this.size; ++i) {
645
- if (this.getAt(i) === element) {
646
- return new DequeIterator<E>(i, this);
647
- }
648
- }
649
- return this.end();
650
- }
651
-
652
513
  /**
653
514
  * Time Complexity: O(n)
654
515
  * Space Complexity: O(1)
@@ -4,3 +4,9 @@ export type HashMapLinkedNode<K, V> = {
4
4
  next: HashMapLinkedNode<K, V>;
5
5
  prev: HashMapLinkedNode<K, V>;
6
6
  };
7
+
8
+ export type HashMapOptions<K, V> = {
9
+ elements: Iterable<[K, V]>;
10
+ hashFn: (key: K) => string;
11
+ objHashFn: (key: K) => object
12
+ }
@@ -1,8 +1,4 @@
1
- export * from './coordinate-map';
2
- export * from './coordinate-set';
3
1
  export * from './hash-map';
4
2
  export * from './hash-table';
5
- export * from './tree-map';
6
- export * from './tree-set';
7
3
 
8
4
  export type HashFunction<K> = (key: K) => number;
@@ -93,7 +93,7 @@ export const throwRangeError = (message = 'The value is off-limits.'): void => {
93
93
  throw new RangeError(message);
94
94
  };
95
95
 
96
- export const isObjOrFunc = (input: unknown): input is Record<string, unknown> | ((...args: any[]) => any) => {
96
+ export const isWeakKey = (input: unknown): input is object => {
97
97
  const inputType = typeof input;
98
98
  return (inputType === 'object' && input !== null) || inputType === 'function';
99
99
  };
@@ -1,44 +0,0 @@
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
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- */
11
- class CoordinateMap extends Map {
12
- constructor(joint) {
13
- super();
14
- this._joint = '_';
15
- if (joint !== undefined)
16
- this._joint = joint;
17
- }
18
- get joint() {
19
- return this._joint;
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
- */
28
- has(key) {
29
- return super.has(key.join(this._joint));
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
- */
39
- set(key, value) {
40
- return super.set(key.join(this._joint), value);
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
- */
48
- get(key) {
49
- return super.get(key.join(this._joint));
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
- */
58
- delete(key) {
59
- return super.delete(key.join(this._joint));
60
- }
61
- }
62
- exports.CoordinateMap = CoordinateMap;
@@ -1,36 +0,0 @@
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
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- */
11
- class CoordinateSet extends Set {
12
- constructor(joint) {
13
- super();
14
- this._joint = '_';
15
- if (joint !== undefined)
16
- this._joint = joint;
17
- }
18
- get joint() {
19
- return this._joint;
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
- */
28
- has(value) {
29
- return super.has(value.join(this._joint));
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
- */
38
- add(value) {
39
- return super.add(value.join(this._joint));
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
- */
48
- delete(value) {
49
- return super.delete(value.join(this._joint));
50
- }
51
- }
52
- exports.CoordinateSet = CoordinateSet;
@@ -1,2 +0,0 @@
1
- export declare class TreeMap {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TreeMap = void 0;
4
- class TreeMap {
5
- }
6
- exports.TreeMap = TreeMap;
@@ -1,2 +0,0 @@
1
- export declare class TreeSet {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TreeSet = void 0;
4
- class TreeSet {
5
- }
6
- exports.TreeSet = TreeSet;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,63 +0,0 @@
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 class CoordinateMap<V> extends Map<any, V> {
9
- constructor(joint?: string) {
10
- super();
11
- if (joint !== undefined) this._joint = joint;
12
- }
13
-
14
- protected _joint = '_';
15
-
16
- get joint(): string {
17
- return this._joint;
18
- }
19
-
20
- /**
21
- * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
22
- * key array with a specified delimiter.
23
- * @param {number[]} key - The parameter "key" is an array of numbers.
24
- * @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
25
- * (`super.has`) with the `key` array joined together using the `_joint` property.
26
- */
27
- override has(key: number[]) {
28
- return super.has(key.join(this._joint));
29
- }
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
- */
39
- override set(key: number[], value: V) {
40
- return super.set(key.join(this._joint), value);
41
- }
42
-
43
- /**
44
- * The function overrides the get method to join the key array with a specified joint and then calls the super get
45
- * method.
46
- * @param {number[]} key - An array of numbers
47
- * @returns The code is returning the value associated with the specified key in the map.
48
- */
49
- override get(key: number[]) {
50
- return super.get(key.join(this._joint));
51
- }
52
-
53
- /**
54
- * The function overrides the delete method and joins the key array using a specified joint character before calling
55
- * the super delete method.
56
- * @param {number[]} key - An array of numbers that represents the key to be deleted.
57
- * @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
58
- * `key` array joined together using the `_joint` property.
59
- */
60
- override delete(key: number[]) {
61
- return super.delete(key.join(this._joint));
62
- }
63
- }
@@ -1,52 +0,0 @@
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 class CoordinateSet extends Set<any> {
9
- constructor(joint?: string) {
10
- super();
11
- if (joint !== undefined) this._joint = joint;
12
- }
13
-
14
- protected _joint = '_';
15
-
16
- get joint(): string {
17
- return this._joint;
18
- }
19
-
20
- /**
21
- * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
22
- * joining its elements with a specified separator.
23
- * @param {number[]} value - The parameter "value" is an array of numbers.
24
- * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
25
- * in the joined value as an argument.
26
- */
27
- override has(value: number[]) {
28
- return super.has(value.join(this._joint));
29
- }
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
- */
38
- override add(value: number[]) {
39
- return super.add(value.join(this._joint));
40
- }
41
-
42
- /**
43
- * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
44
- * array with a specified joint and then calling the delete method of the parent class.
45
- * @param {number[]} value - An array of numbers
46
- * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
47
- * `value` array joined together using the `_joint` property.
48
- */
49
- override delete(value: number[]) {
50
- return super.delete(value.join(this._joint));
51
- }
52
- }
@@ -1,2 +0,0 @@
1
- export class TreeMap {
2
- }
@@ -1,2 +0,0 @@
1
- export class TreeSet {
2
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};