linked-list-typed 1.39.0 → 1.39.1

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 (49) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +2 -2
  2. package/dist/data-structures/binary-tree/binary-tree.d.ts +86 -32
  3. package/dist/data-structures/binary-tree/binary-tree.js +8 -8
  4. package/dist/data-structures/binary-tree/bst.d.ts +6 -6
  5. package/dist/data-structures/binary-tree/bst.js +2 -2
  6. package/dist/data-structures/binary-tree/tree-multiset.d.ts +2 -2
  7. package/dist/data-structures/graph/abstract-graph.d.ts +1 -1
  8. package/dist/data-structures/graph/abstract-graph.js +1 -1
  9. package/dist/data-structures/graph/map-graph.d.ts +1 -1
  10. package/dist/data-structures/graph/map-graph.js +1 -1
  11. package/dist/data-structures/matrix/matrix2d.d.ts +1 -2
  12. package/dist/data-structures/matrix/matrix2d.js +3 -7
  13. package/dist/data-structures/matrix/vector2d.d.ts +0 -1
  14. package/dist/data-structures/matrix/vector2d.js +0 -1
  15. package/dist/interfaces/binary-tree.d.ts +2 -2
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
  17. package/dist/types/helpers.d.ts +1 -4
  18. package/package.json +1 -1
  19. package/src/data-structures/binary-tree/avl-tree.ts +5 -4
  20. package/src/data-structures/binary-tree/binary-indexed-tree.ts +1 -1
  21. package/src/data-structures/binary-tree/binary-tree.ts +37 -93
  22. package/src/data-structures/binary-tree/bst.ts +11 -17
  23. package/src/data-structures/binary-tree/rb-tree.ts +2 -1
  24. package/src/data-structures/binary-tree/tree-multiset.ts +4 -3
  25. package/src/data-structures/graph/abstract-graph.ts +12 -11
  26. package/src/data-structures/graph/directed-graph.ts +2 -1
  27. package/src/data-structures/graph/map-graph.ts +2 -2
  28. package/src/data-structures/graph/undirected-graph.ts +5 -4
  29. package/src/data-structures/hash/hash-map.ts +1 -1
  30. package/src/data-structures/hash/tree-map.ts +1 -2
  31. package/src/data-structures/hash/tree-set.ts +1 -2
  32. package/src/data-structures/heap/heap.ts +2 -2
  33. package/src/data-structures/heap/max-heap.ts +1 -1
  34. package/src/data-structures/heap/min-heap.ts +1 -1
  35. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  36. package/src/data-structures/matrix/matrix.ts +1 -1
  37. package/src/data-structures/matrix/matrix2d.ts +1 -3
  38. package/src/data-structures/matrix/vector2d.ts +1 -4
  39. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  40. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  41. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  42. package/src/data-structures/queue/deque.ts +4 -5
  43. package/src/data-structures/queue/queue.ts +1 -1
  44. package/src/interfaces/binary-tree.ts +2 -2
  45. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -4
  46. package/src/types/data-structures/matrix/navigator.ts +1 -1
  47. package/src/types/helpers.ts +1 -7
  48. package/src/types/utils/utils.ts +1 -1
  49. package/src/types/utils/validate-type.ts +2 -2
@@ -10,7 +10,7 @@ import type {Comparator} from '../../types';
10
10
 
11
11
  export class MinPriorityQueue<E = any> extends PriorityQueue<E> {
12
12
  constructor(
13
- options: { comparator: Comparator<E>; nodes?: E[] } = {
13
+ options: {comparator: Comparator<E>; nodes?: E[]} = {
14
14
  comparator: (a: E, b: E) => {
15
15
  if (!(typeof a === 'number' && typeof b === 'number')) {
16
16
  throw new Error('The a, b params of compare function must be number');
@@ -10,7 +10,7 @@ import {Heap} from '../heap';
10
10
  import {Comparator} from '../../types';
11
11
 
12
12
  export class PriorityQueue<E = any> extends Heap<E> {
13
- constructor(options: { comparator: Comparator<E>; nodes?: E[] }) {
13
+ constructor(options: {comparator: Comparator<E>; nodes?: E[]}) {
14
14
  super(options);
15
15
  }
16
16
  }
@@ -9,8 +9,7 @@ import {DoublyLinkedList} from '../linked-list';
9
9
 
10
10
  // O(n) time complexity of obtaining the value
11
11
  // O(1) time complexity of adding at the beginning and the end
12
- export class Deque<E = any> extends DoublyLinkedList<E> {
13
- }
12
+ export class Deque<E = any> extends DoublyLinkedList<E> {}
14
13
 
15
14
  // O(1) time complexity of obtaining the value
16
15
  // O(n) time complexity of adding at the beginning and the end
@@ -20,9 +19,9 @@ export class ObjectDeque<E = number> {
20
19
  if (capacity !== undefined) this._capacity = capacity;
21
20
  }
22
21
 
23
- private _nodes: { [key: number]: E } = {};
22
+ private _nodes: {[key: number]: E} = {};
24
23
 
25
- get nodes(): { [p: number]: E } {
24
+ get nodes(): {[p: number]: E} {
26
25
  return this._nodes;
27
26
  }
28
27
 
@@ -157,7 +156,7 @@ export class ObjectDeque<E = number> {
157
156
  return this._size <= 0;
158
157
  }
159
158
 
160
- protected _seNodes(value: { [p: number]: E }) {
159
+ protected _seNodes(value: {[p: number]: E}) {
161
160
  this._nodes = value;
162
161
  }
163
162
 
@@ -183,7 +183,7 @@ export class Queue<E = any> {
183
183
  return new Queue(this.nodes.slice(this.offset));
184
184
  }
185
185
 
186
- * [Symbol.iterator]() {
186
+ *[Symbol.iterator]() {
187
187
  for (const item of this.nodes) {
188
188
  yield item;
189
189
  }
@@ -1,10 +1,10 @@
1
1
  import {BinaryTreeNode} from '../data-structures';
2
- import {BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodeNested, MapCallback} from '../types';
2
+ import {BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodeNested, OneParamCallback} from '../types';
3
3
 
4
4
  export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
5
5
  createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
6
6
 
7
7
  add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
8
8
 
9
- delete<C extends MapCallback<N>>(identifier: ReturnType<C> | N, callback: C): BinaryTreeDeletedResult<N>[];
9
+ delete<C extends OneParamCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeletedResult<N>[];
10
10
  }
@@ -24,10 +24,6 @@ export enum FamilyPosition {
24
24
 
25
25
  export type BinaryTreeNodeKey = number;
26
26
 
27
- export type BFSCallback<N, D = any> = (node: N, level?: number) => D;
28
-
29
- export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;
30
-
31
27
  export type BinaryTreeDeletedResult<N> = { deleted: N | null | undefined; needBalanced: N | null };
32
28
 
33
29
  export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -1,6 +1,6 @@
1
1
  export type Direction = 'up' | 'right' | 'down' | 'left';
2
2
 
3
- export type Turning = { [key in Direction]: Direction };
3
+ export type Turning = {[key in Direction]: Direction};
4
4
 
5
5
  export type NavigatorParams<T = any> = {
6
6
  matrix: T[][];
@@ -1,14 +1,8 @@
1
- import {BinaryTreeNodeKey} from './data-structures';
2
-
3
1
  export type Comparator<T> = (a: T, b: T) => number;
4
2
 
5
3
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
6
4
 
7
- export type MapCallback<N, D = any> = (node: N) => D;
8
-
9
- export type DefaultMapCallback<N, D = BinaryTreeNodeKey> = (node: N) => D;
10
-
11
- export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
5
+ export type OneParamCallback<N, D = any> = (node: N) => D;
12
6
 
13
7
  export enum CP {
14
8
  lt = 'lt',
@@ -1,5 +1,5 @@
1
1
  export type ToThunkFn = () => ReturnType<TrlFn>;
2
- export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
2
+ export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
3
3
  export type TrlFn = (...args: any[]) => any;
4
4
  export type TrlAsyncFn = (...args: any[]) => any;
5
5
 
@@ -1,6 +1,6 @@
1
- export type KeyValueObject = { [key: string]: any };
1
+ export type KeyValueObject = {[key: string]: any};
2
2
 
3
- export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
3
+ export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
4
4
 
5
5
  export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
6
6