[prettier] bracket spacing false

This commit is contained in:
Revone 2023-09-22 10:43:16 +08:00
parent 25c88edcd6
commit ea8f993a4a
36 changed files with 129 additions and 135 deletions

View file

@ -1,6 +1,6 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
bracketSpacing: false,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
bracketSameLine: false,

View file

@ -6,7 +6,7 @@
* @license MIT License
*/
import { trampoline } from '../../utils';
import {trampoline} from '../../utils';
import type {
AbstractBinaryTreeNodeNested,
AbstractBinaryTreeNodeProperties,
@ -17,8 +17,8 @@ import type {
DFSOrderPattern,
NodeOrPropertyName
} from '../../types';
import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../../types';
import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../../interfaces';
import {AbstractBinaryTreeOptions, FamilyPosition, LoopType} from '../../types';
import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from '../../interfaces';
export abstract class AbstractBinaryTreeNode<
T = any,
@ -145,7 +145,7 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
*/
protected constructor(options?: AbstractBinaryTreeOptions) {
if (options !== undefined) {
const { loopType = LoopType.ITERATIVE } = options;
const {loopType = LoopType.ITERATIVE} = options;
this._loopType = loopType;
}
this.clear();
@ -203,7 +203,7 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
* @returns The `destNode` is being returned.
*/
swapLocation(srcNode: N, destNode: N): N {
const { id, val, height } = destNode;
const {id, val, height} = destNode;
const tempNode = this.createNode(id, val);
if (tempNode) {
@ -377,7 +377,7 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
if (!parent) {
if (curr.right !== undefined) this._setRoot(curr.right);
} else {
const { familyPosition: fp } = curr;
const {familyPosition: fp} = curr;
if (fp === FamilyPosition.LEFT || fp === FamilyPosition.ROOT_LEFT) {
parent.left = curr.right;
} else if (fp === FamilyPosition.RIGHT || fp === FamilyPosition.ROOT_RIGHT) {
@ -400,7 +400,7 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
}
this._setSize(this.size - 1);
bstDeletedResult.push({ deleted: orgCurrent, needBalanced });
bstDeletedResult.push({deleted: orgCurrent, needBalanced});
return bstDeletedResult;
}
@ -447,18 +447,18 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
return -1;
}
const stack: { node: N; depth: number }[] = [{ node: beginRoot, depth: 0 }];
const stack: {node: N; depth: number}[] = [{node: beginRoot, depth: 0}];
let maxHeight = 0;
while (stack.length > 0) {
const { node, depth } = stack.pop()!;
const {node, depth} = stack.pop()!;
if (node.left) {
stack.push({ node: node.left, depth: depth + 1 });
stack.push({node: node.left, depth: depth + 1});
}
if (node.right) {
stack.push({ node: node.right, depth: depth + 1 });
stack.push({node: node.right, depth: depth + 1});
}
maxHeight = Math.max(maxHeight, depth);
@ -1086,7 +1086,7 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
this._clearResults();
if (!this.root) return this._getResultByPropertyName(nodeOrPropertyName);
// 0: visit, 1: print
const stack: { opt: 0 | 1; node: N | null | undefined }[] = [{ opt: 0, node: this.root }];
const stack: {opt: 0 | 1; node: N | null | undefined}[] = [{opt: 0, node: this.root}];
while (stack.length > 0) {
const cur = stack.pop();
@ -1096,24 +1096,24 @@ export abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val
} else {
switch (pattern) {
case 'in':
stack.push({ opt: 0, node: cur.node.right });
stack.push({ opt: 1, node: cur.node });
stack.push({ opt: 0, node: cur.node.left });
stack.push({opt: 0, node: cur.node.right});
stack.push({opt: 1, node: cur.node});
stack.push({opt: 0, node: cur.node.left});
break;
case 'pre':
stack.push({ opt: 0, node: cur.node.right });
stack.push({ opt: 0, node: cur.node.left });
stack.push({ opt: 1, node: cur.node });
stack.push({opt: 0, node: cur.node.right});
stack.push({opt: 0, node: cur.node.left});
stack.push({opt: 1, node: cur.node});
break;
case 'post':
stack.push({ opt: 1, node: cur.node });
stack.push({ opt: 0, node: cur.node.right });
stack.push({ opt: 0, node: cur.node.left });
stack.push({opt: 1, node: cur.node});
stack.push({opt: 0, node: cur.node.right});
stack.push({opt: 0, node: cur.node.left});
break;
default:
stack.push({ opt: 0, node: cur.node.right });
stack.push({ opt: 1, node: cur.node });
stack.push({ opt: 0, node: cur.node.left });
stack.push({opt: 0, node: cur.node.right});
stack.push({opt: 1, node: cur.node});
stack.push({opt: 0, node: cur.node.left});
break;
}
}

View file

@ -5,9 +5,9 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { BST, BSTNode } from './bst';
import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId } from '../../types';
import { IAVLTree, IAVLTreeNode } from '../../interfaces';
import {BST, BSTNode} from './bst';
import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId} from '../../types';
import {IAVLTree, IAVLTreeNode} from '../../interfaces';
export class AVLTreeNode<T = any, NEIGHBOR extends AVLTreeNode<T, NEIGHBOR> = AVLTreeNodeNested<T>>
extends BSTNode<T, NEIGHBOR>
@ -67,7 +67,7 @@ export class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends B
*/
override remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[] {
const deletedResults = super.remove(id, isUpdateAllLeftSum);
for (const { needBalanced } of deletedResults) {
for (const {needBalanced} of deletedResults) {
if (needBalanced) {
this._balancePath(needBalanced);
}

View file

@ -6,9 +6,9 @@
* @license MIT License
*/
import type { BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions } from '../../types';
import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
import { IBinaryTree, IBinaryTreeNode } from '../../interfaces';
import type {BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions} from '../../types';
import {AbstractBinaryTree, AbstractBinaryTreeNode} from './abstract-binary-tree';
import {IBinaryTree, IBinaryTreeNode} from '../../interfaces';
export class BinaryTreeNode<T = any, NEIGHBOR extends BinaryTreeNode<T, NEIGHBOR> = BinaryTreeNodeNested<T>>
extends AbstractBinaryTreeNode<T, NEIGHBOR>

View file

@ -5,16 +5,10 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type {
BinaryTreeNodeId,
BinaryTreeNodePropertyName,
BSTComparator,
BSTNodeNested,
BSTOptions
} from '../../types';
import { CP, LoopType } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';
import { IBST, IBSTNode } from '../../interfaces';
import type {BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions} from '../../types';
import {CP, LoopType} from '../../types';
import {BinaryTree, BinaryTreeNode} from './binary-tree';
import {IBST, IBSTNode} from '../../interfaces';
export class BSTNode<T = any, NEIGHBOR extends BSTNode<T, NEIGHBOR> = BSTNodeNested<T>>
extends BinaryTreeNode<T, NEIGHBOR>
@ -33,7 +27,7 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
constructor(options?: BSTOptions) {
super(options);
if (options !== undefined) {
const { comparator } = options;
const {comparator} = options;
if (comparator !== undefined) {
this._comparator = comparator;
}

View file

@ -1,6 +1,6 @@
import { BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types';
import { IRBTree, IRBTreeNode } from '../../interfaces/rb-tree';
import { BST, BSTNode } from './bst';
import {BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions} from '../../types';
import {IRBTree, IRBTreeNode} from '../../interfaces/rb-tree';
import {BST, BSTNode} from './bst';
export class RBTreeNode<T = any, NEIGHBOR extends RBTreeNode<T, NEIGHBOR> = RBTreeNodeNested<T>>
extends BSTNode<T, NEIGHBOR>

View file

@ -6,7 +6,7 @@
* @license MIT License
*/
import type { SegmentTreeNodeVal } from '../../types';
import type {SegmentTreeNodeVal} from '../../types';
export class SegmentTreeNode {
constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null) {

View file

@ -5,10 +5,10 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions } from '../../types';
import { BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType } from '../../types';
import { ITreeMultiset, ITreeMultisetNode } from '../../interfaces';
import { AVLTree, AVLTreeNode } from './avl-tree';
import type {BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types';
import {BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType} from '../../types';
import {ITreeMultiset, ITreeMultisetNode} from '../../interfaces';
import {AVLTree, AVLTreeNode} from './avl-tree';
export class TreeMultisetNode<T = any, NEIGHBOR extends TreeMultisetNode<T, NEIGHBOR> = TreeMultisetNodeNested<T>>
extends AVLTreeNode<T, NEIGHBOR>
@ -54,7 +54,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
* TreeMultiset.
*/
constructor(options?: TreeMultisetOptions) {
super({ ...options });
super({...options});
}
private _count = 0;
@ -84,7 +84,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
* @returns the `destNode` after swapping its values with the `srcNode`.
*/
override swapLocation(srcNode: N, destNode: N): N {
const { id, val, count, height } = destNode;
const {id, val, count, height} = destNode;
const tempNode = this.createNode(id, val, count);
if (tempNode) {
tempNode.height = height;
@ -321,7 +321,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
if (!parent) {
if (curr.right !== undefined) this._setRoot(curr.right);
} else {
const { familyPosition: fp } = curr;
const {familyPosition: fp} = curr;
if (fp === FamilyPosition.LEFT || fp === FamilyPosition.ROOT_LEFT) {
parent.left = curr.right;
} else if (fp === FamilyPosition.RIGHT || fp === FamilyPosition.ROOT_RIGHT) {
@ -349,7 +349,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
this._setCount(this.count - orgCurrent.count);
}
bstDeletedResult.push({ deleted: orgCurrent, needBalanced });
bstDeletedResult.push({deleted: orgCurrent, needBalanced});
if (needBalanced) {
this._balancePath(needBalanced);

View file

@ -5,10 +5,10 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { arrayRemove, uuidV4 } from '../../utils';
import { PriorityQueue } from '../priority-queue';
import type { DijkstraResult, VertexId } from '../../types';
import { IAbstractGraph } from '../../interfaces';
import {arrayRemove, uuidV4} from '../../utils';
import {PriorityQueue} from '../priority-queue';
import type {DijkstraResult, VertexId} from '../../types';
import {IAbstractGraph} from '../../interfaces';
export abstract class AbstractVertex<T = any> {
/**
@ -530,7 +530,7 @@ export abstract class AbstractGraph<
if (genPaths) {
getPaths(destVertex);
}
return { distMap, preMap, seen, paths, minDist, minPath };
return {distMap, preMap, seen, paths, minDist, minPath};
}
const neighbors = this.getNeighbors(cur);
for (const neighbor of neighbors) {
@ -564,7 +564,7 @@ export abstract class AbstractGraph<
genPaths && getPaths(minDest);
return { distMap, preMap, seen, paths, minDist, minPath };
return {distMap, preMap, seen, paths, minDist, minPath};
}
/**
@ -617,10 +617,10 @@ export abstract class AbstractGraph<
if (vertexOrId instanceof AbstractVertex) distMap.set(vertexOrId, Infinity);
}
const heap = new PriorityQueue<{ id: number; val: V }>({
const heap = new PriorityQueue<{id: number; val: V}>({
comparator: (a, b) => a.id - b.id
});
heap.add({ id: 0, val: srcVertex });
heap.add({id: 0, val: srcVertex});
distMap.set(srcVertex, 0);
preMap.set(srcVertex, null);
@ -661,7 +661,7 @@ export abstract class AbstractGraph<
if (genPaths) {
getPaths(destVertex);
}
return { distMap, preMap, seen, paths, minDist, minPath };
return {distMap, preMap, seen, paths, minDist, minPath};
}
const neighbors = this.getNeighbors(cur);
for (const neighbor of neighbors) {
@ -671,7 +671,7 @@ export abstract class AbstractGraph<
const distSrcToNeighbor = distMap.get(neighbor);
if (distSrcToNeighbor) {
if (dist + weight < distSrcToNeighbor) {
heap.add({ id: dist + weight, val: neighbor });
heap.add({id: dist + weight, val: neighbor});
preMap.set(neighbor, cur);
distMap.set(neighbor, dist + weight);
}
@ -698,7 +698,7 @@ export abstract class AbstractGraph<
getPaths(minDest);
}
return { distMap, preMap, seen, paths, minDist, minPath };
return {distMap, preMap, seen, paths, minDist, minPath};
}
/**
@ -735,7 +735,7 @@ export abstract class AbstractGraph<
// TODO
let hasNegativeCycle: boolean | undefined;
if (scanNegativeCycle) hasNegativeCycle = false;
if (!srcVertex) return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
if (!srcVertex) return {hasNegativeCycle, distMap, preMap, paths, min, minPath};
const vertices = this._vertices;
const numOfVertices = vertices.size;
@ -807,7 +807,7 @@ export abstract class AbstractGraph<
}
}
return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
return {hasNegativeCycle, distMap, preMap, paths, min, minPath};
}
/**
@ -848,7 +848,7 @@ export abstract class AbstractGraph<
* `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
* path between vertices in the
*/
floyd(): { costs: number[][]; predecessor: (V | null)[][] } {
floyd(): {costs: number[][]; predecessor: (V | null)[][]} {
const idAndVertices = [...this._vertices];
const n = idAndVertices.length;
@ -880,7 +880,7 @@ export abstract class AbstractGraph<
}
}
}
return { costs, predecessor };
return {costs, predecessor};
}
/**
@ -1011,7 +1011,7 @@ export abstract class AbstractGraph<
});
}
return { dfnMap, lowMap, bridges, articulationPoints, SCCs, cycles };
return {dfnMap, lowMap, bridges, articulationPoints, SCCs, cycles};
}
protected abstract _addEdgeOnly(edge: E): boolean;

View file

@ -5,10 +5,10 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { arrayRemove } from '../../utils';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import type { TopologicalStatus, VertexId } from '../../types';
import { IDirectedGraph } from '../../interfaces';
import {arrayRemove} from '../../utils';
import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
import type {TopologicalStatus, VertexId} from '../../types';
import {IDirectedGraph} from '../../interfaces';
export class DirectedVertex<T = number> extends AbstractVertex<T> {
/**

View file

@ -1,5 +1,5 @@
import { MapGraphCoordinate, VertexId } from '../../types';
import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
import {MapGraphCoordinate, VertexId} from '../../types';
import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph';
export class MapVertex<T = any> extends DirectedVertex<T> {
/**

View file

@ -5,10 +5,10 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { arrayRemove } from '../../utils';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import type { VertexId } from '../../types';
import { IUNDirectedGraph } from '../../interfaces';
import {arrayRemove} from '../../utils';
import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
import type {VertexId} from '../../types';
import {IUNDirectedGraph} from '../../interfaces';
export class UndirectedVertex<T = number> extends AbstractVertex<T> {
/**

View file

@ -5,8 +5,8 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { PriorityQueue } from '../priority-queue';
import type { HeapOptions } from '../../types';
import {PriorityQueue} from '../priority-queue';
import type {HeapOptions} from '../../types';
export class HeapItem<T = number> {
/**
@ -50,7 +50,7 @@ export abstract class Heap<T = number> {
*/
protected constructor(options?: HeapOptions<T>) {
if (options) {
const { priorityExtractor } = options;
const {priorityExtractor} = options;
if (priorityExtractor !== undefined && typeof priorityExtractor !== 'function') {
throw new Error('.constructor expects a valid priority function');
}

View file

@ -6,9 +6,9 @@
* @license MIT License
*/
import { Heap, HeapItem } from './heap';
import { PriorityQueue } from '../priority-queue';
import type { HeapOptions } from '../../types';
import {Heap, HeapItem} from './heap';
import {PriorityQueue} from '../priority-queue';
import type {HeapOptions} from '../../types';
/**
* @class MaxHeap

View file

@ -6,9 +6,9 @@
* @license MIT License
*/
import { Heap, HeapItem } from './heap';
import { PriorityQueue } from '../priority-queue';
import type { HeapOptions } from '../../types';
import {Heap, HeapItem} from './heap';
import {PriorityQueue} from '../priority-queue';
import type {HeapOptions} from '../../types';
/**
* @class MinHeap

View file

@ -14,8 +14,8 @@ export class MatrixNTI2D<T = number> {
* given initial value or 0 if not provided.
* @param options - An object containing the following properties:
*/
constructor(options: { row: number; col: number; initialVal?: T }) {
const { row, col, initialVal } = options;
constructor(options: {row: number; col: number; initialVal?: T}) {
const {row, col, initialVal} = options;
this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0));
}

View file

@ -5,7 +5,7 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { Direction, NavigatorParams, Turning } from '../../types';
import type {Direction, NavigatorParams, Turning} from '../../types';
export class Character {
direction: Direction;
@ -37,7 +37,7 @@ export class Navigator<T = number> {
* in the matrix.
* @param - - `matrix`: a 2D array representing the grid or map
*/
constructor({ matrix, turning, onMove, init: { cur, charDir, VISITED } }: NavigatorParams<T>) {
constructor({matrix, turning, onMove, init: {cur, charDir, VISITED}}: NavigatorParams<T>) {
this._matrix = matrix;
this._cur = cur;
this._character = new Character(charDir, turning);
@ -53,7 +53,7 @@ export class Navigator<T = number> {
*/
start() {
while (this.check(this._character.direction) || this.check(this._character.turn().direction)) {
const { direction } = this._character;
const {direction} = this._character;
if (this.check(direction)) {
this.move(direction);
} else if (this.check(this._character.turn().direction)) {

View file

@ -5,8 +5,8 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions, SpecifyOptional } from '../../types';
import {PriorityQueue} from './priority-queue';
import type {PriorityQueueOptions, SpecifyOptional} from '../../types';
export class MaxPriorityQueue<T = number> extends PriorityQueue<T> {
constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);

View file

@ -5,8 +5,8 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions, SpecifyOptional } from '../../types';
import {PriorityQueue} from './priority-queue';
import type {PriorityQueueOptions, SpecifyOptional} from '../../types';
export class MinPriorityQueue<T = number> extends PriorityQueue<T> {
constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);

View file

@ -5,7 +5,7 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../../types';
import type {PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions} from '../../types';
export class PriorityQueue<T = number> {
/**
@ -14,7 +14,7 @@ export class PriorityQueue<T = number> {
* @param options - The `options` parameter is an object that contains the following properties:
*/
constructor(options: PriorityQueueOptions<T>) {
const { nodes, comparator, isFix = true } = options;
const {nodes, comparator, isFix = true} = options;
this._comparator = comparator;
if (nodes && Array.isArray(nodes) && nodes.length > 0) {
@ -55,7 +55,7 @@ export class PriorityQueue<T = number> {
* @returns the result of calling the `isValid()` method on a new instance of the `PriorityQueue` class.
*/
static isPriorityQueueified<T>(options: Omit<PriorityQueueOptions<T>, 'isFix'>) {
return new PriorityQueue({ ...options, isFix: false }).isValid();
return new PriorityQueue({...options, isFix: false}).isValid();
}
/**

View file

@ -5,7 +5,7 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import { DoublyLinkedList } from '../linked-list';
import {DoublyLinkedList} from '../linked-list';
// O(n) time complexity of obtaining the value
// O(1) time complexity of adding at the beginning and the end
@ -19,9 +19,9 @@ export class ObjectDeque<T = number> {
if (capacity !== undefined) this._capacity = capacity;
}
private _nodes: { [key: number]: T } = {};
private _nodes: {[key: number]: T} = {};
get nodes(): { [p: number]: T } {
get nodes(): {[p: number]: T} {
return this._nodes;
}
@ -156,7 +156,7 @@ export class ObjectDeque<T = number> {
return this._size <= 0;
}
protected _seNodes(value: { [p: number]: T }) {
protected _seNodes(value: {[p: number]: T}) {
this._nodes = value;
}

View file

@ -3,7 +3,7 @@
* @copyright Tyler Zeng <zrwusa@gmail.com>
* @class
*/
import { SinglyLinkedList } from '../linked-list';
import {SinglyLinkedList} from '../linked-list';
export class LinkedListQueue<T = any> extends SinglyLinkedList<T> {
/**

View file

@ -55,7 +55,7 @@ export class TreeNode<T = any> {
if (level > maxDepth) {
maxDepth = level;
}
const { children } = node;
const {children} = node;
if (children) {
for (let i = 0, len = children.length; i < len; i++) {
bfs(children[i], level + 1);

View file

@ -9,7 +9,7 @@ import {
LoopType,
NodeOrPropertyName
} from '../types';
import { AbstractBinaryTreeNode } from '../data-structures';
import {AbstractBinaryTreeNode} from '../data-structures';
export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
get id(): BinaryTreeNodeId;

View file

@ -1,4 +1,4 @@
import { VertexId } from '../types';
import {VertexId} from '../types';
export interface IAbstractGraph<V, E> {
hasVertex(vertexOrId: V | VertexId): boolean;

View file

@ -1,6 +1,6 @@
import { AVLTreeNode } from '../data-structures';
import { IBST, IBSTNode } from './bst';
import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types';
import {AVLTreeNode} from '../data-structures';
import {IBST, IBSTNode} from './bst';
import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types';
export type IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;

View file

@ -1,5 +1,5 @@
import { BinaryTreeNode } from '../data-structures';
import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from './abstract-binary-tree';
import {BinaryTreeNode} from '../data-structures';
import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
export type IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> = IAbstractBinaryTreeNode<T, NEIGHBOR>;

View file

@ -1,6 +1,6 @@
import { BSTNode } from '../data-structures';
import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types';
import {BSTNode} from '../data-structures';
import {IBinaryTree, IBinaryTreeNode} from './binary-tree';
import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types';
export type IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> = IBinaryTreeNode<T, NEIGHBOR>;

View file

@ -1,5 +1,5 @@
import { VertexId } from '../types';
import { IAbstractGraph } from './abstract-graph';
import {VertexId} from '../types';
import {IAbstractGraph} from './abstract-graph';
export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
incomingEdgesOf(vertex: V): E[];

View file

@ -1,6 +1,6 @@
import { RBTreeNode } from '../data-structures';
import { IBST, IBSTNode } from './bst';
import { BinaryTreeNodeId } from '../types';
import {RBTreeNode} from '../data-structures';
import {IBST, IBSTNode} from './bst';
import {BinaryTreeNodeId} from '../types';
export type IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;

View file

@ -1,6 +1,6 @@
import { TreeMultisetNode } from '../data-structures';
import { IBSTNode } from './bst';
import { IAVLTree } from './avl-tree';
import {TreeMultisetNode} from '../data-structures';
import {IBSTNode} from './bst';
import {IAVLTree} from './avl-tree';
export type ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;

View file

@ -1,5 +1,5 @@
import { VertexId } from '../types';
import { IAbstractGraph } from './abstract-graph';
import {VertexId} from '../types';
import {IAbstractGraph} from './abstract-graph';
export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;

View file

@ -1,5 +1,5 @@
export type Direction = 'up' | 'right' | 'down' | 'left';
export type Turning = { [key in Direction]: Direction };
export type Turning = {[key in Direction]: Direction};
export type NavigatorParams<T> = {
matrix: T[][];

View file

@ -1,5 +1,5 @@
export type ToThunkFn = () => ReturnType<TrlFn>;
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
export type TrlFn = (...args: any[]) => any;
export type TrlAsyncFn = (...args: any[]) => any;

View file

@ -1,6 +1,6 @@
export type KeyValueObject = { [key: string]: any };
export type KeyValueObject = {[key: string]: any};
export type KeyValueObjectWithId = { [key: string]: any; id: string | number | symbol };
export type KeyValueObjectWithId = {[key: string]: any; id: string | number | symbol};
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;

View file

@ -5,7 +5,7 @@
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types';
export const uuidV4 = function () {
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
@ -57,7 +57,7 @@ export const trampoline = (fn: TrlFn) => {
return result;
},
{ cont }
{cont}
);
};
@ -74,6 +74,6 @@ export const trampolineAsync = (fn: TrlAsyncFn) => {
return result;
},
{ cont }
{cont}
);
};