mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
style: Change ESLint configuration from error type to warning type. Format the code.
This commit is contained in:
parent
dd2701dab7
commit
be6ad5473b
|
@ -1,8 +1,8 @@
|
|||
module.exports = {
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"import",
|
||||
"@typescript-eslint"
|
||||
"@typescript-eslint",
|
||||
"eslint-plugin-import"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"lines-around-comment": [
|
||||
"error",
|
||||
"warn",
|
||||
{
|
||||
"beforeLineComment": false,
|
||||
"beforeBlockComment": true,
|
||||
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
],
|
||||
"newline-before-return": "off",
|
||||
"import/newline-after-import": [
|
||||
"error",
|
||||
"warn",
|
||||
{
|
||||
"count": 1
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ export class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNeste
|
|||
|
||||
export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>>
|
||||
extends BST<V, N>
|
||||
implements IBinaryTree<V, N>
|
||||
{
|
||||
implements IBinaryTree<V, N> {
|
||||
/**
|
||||
* This is a constructor function for an AVL tree data structure in TypeScript.
|
||||
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|
||||
|
@ -210,7 +209,7 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
|
|||
// Balance Restoration: If a balance issue is discovered after inserting a node, it requires balance restoration operations. Balance restoration includes four basic cases where rotation operations need to be performed to fix the balance:
|
||||
switch (
|
||||
this._balanceFactor(A) // second O(1)
|
||||
) {
|
||||
) {
|
||||
case -2:
|
||||
if (A && A.left) {
|
||||
if (this._balanceFactor(A.left) <= 0) {
|
||||
|
|
|
@ -108,8 +108,7 @@ export class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = BinaryTree
|
|||
* @template N - The type of the binary tree's nodes.
|
||||
*/
|
||||
export class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNode<V, BinaryTreeNodeNested<V>>>
|
||||
implements IBinaryTree<V, N>
|
||||
{
|
||||
implements IBinaryTree<V, N> {
|
||||
iterationType: IterationType = IterationType.ITERATIVE;
|
||||
|
||||
/**
|
||||
|
@ -1695,7 +1694,7 @@ export class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNode
|
|||
* @returns The `*[Symbol.iterator]` method returns a generator object that yields the keys of the
|
||||
* binary tree nodes in a specific order.
|
||||
*/
|
||||
*[Symbol.iterator](node = this.root): Generator<BTNKey, void, undefined> {
|
||||
* [Symbol.iterator](node = this.root): Generator<BTNKey, void, undefined> {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ export class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extend
|
|||
|
||||
export class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>>
|
||||
extends BinaryTree<V, N>
|
||||
implements IBinaryTree<V, N>
|
||||
{
|
||||
implements IBinaryTree<V, N> {
|
||||
/**
|
||||
* The constructor function initializes a binary search tree with an optional comparator function.
|
||||
* @param {BSTOptions} [options] - An optional object that contains additional configuration options
|
||||
|
|
|
@ -40,8 +40,7 @@ export class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N> = RedBla
|
|||
*/
|
||||
export class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>>
|
||||
extends BST<V, N>
|
||||
implements IBinaryTree<V, N>
|
||||
{
|
||||
implements IBinaryTree<V, N> {
|
||||
NIL: N = new RedBlackTreeNode<V>(NaN) as unknown as N;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,8 +37,7 @@ export class TreeMultimapNode<
|
|||
*/
|
||||
export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNode<V, TreeMultimapNodeNested<V>>>
|
||||
extends AVLTree<V, N>
|
||||
implements IBinaryTree<V, N>
|
||||
{
|
||||
implements IBinaryTree<V, N> {
|
||||
/**
|
||||
* The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
|
||||
* merge duplicated values.
|
||||
|
|
|
@ -64,8 +64,7 @@ export abstract class AbstractGraph<
|
|||
E = any,
|
||||
VO extends AbstractVertex<V> = AbstractVertex<V>,
|
||||
EO extends AbstractEdge<E> = AbstractEdge<E>
|
||||
> implements IGraph<V, E, VO, EO>
|
||||
{
|
||||
> implements IGraph<V, E, VO, EO> {
|
||||
protected _vertices: Map<VertexKey, VO> = new Map<VertexKey, VO>();
|
||||
|
||||
get vertices(): Map<VertexKey, VO> {
|
||||
|
@ -615,14 +614,14 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
|
||||
getMinDist &&
|
||||
distMap.forEach((d, v) => {
|
||||
if (v !== srcVertex) {
|
||||
if (d < minDist) {
|
||||
minDist = d;
|
||||
if (genPaths) minDest = v;
|
||||
}
|
||||
distMap.forEach((d, v) => {
|
||||
if (v !== srcVertex) {
|
||||
if (d < minDist) {
|
||||
minDist = d;
|
||||
if (genPaths) minDest = v;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
genPaths && getPaths(minDest);
|
||||
|
||||
|
|
|
@ -46,14 +46,13 @@ export class DirectedEdge<E = any> extends AbstractEdge<E> {
|
|||
}
|
||||
|
||||
export class DirectedGraph<
|
||||
V = any,
|
||||
E = any,
|
||||
VO extends DirectedVertex<V> = DirectedVertex<V>,
|
||||
EO extends DirectedEdge<E> = DirectedEdge<E>
|
||||
>
|
||||
V = any,
|
||||
E = any,
|
||||
VO extends DirectedVertex<V> = DirectedVertex<V>,
|
||||
EO extends DirectedEdge<E> = DirectedEdge<E>
|
||||
>
|
||||
extends AbstractGraph<V, E, VO, EO>
|
||||
implements IGraph<V, E, VO, EO>
|
||||
{
|
||||
implements IGraph<V, E, VO, EO> {
|
||||
/**
|
||||
* The constructor function initializes an instance of a class.
|
||||
*/
|
||||
|
|
|
@ -43,14 +43,13 @@ export class UndirectedEdge<E = number> extends AbstractEdge<E> {
|
|||
}
|
||||
|
||||
export class UndirectedGraph<
|
||||
V = any,
|
||||
E = any,
|
||||
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
|
||||
EO extends UndirectedEdge<E> = UndirectedEdge<E>
|
||||
>
|
||||
V = any,
|
||||
E = any,
|
||||
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
|
||||
EO extends UndirectedEdge<E> = UndirectedEdge<E>
|
||||
>
|
||||
extends AbstractGraph<V, E, VO, EO>
|
||||
implements IGraph<V, E, VO, EO>
|
||||
{
|
||||
implements IGraph<V, E, VO, EO> {
|
||||
/**
|
||||
* The constructor initializes a new Map object to store edges.
|
||||
*/
|
||||
|
|
|
@ -459,7 +459,7 @@ export class HashMap<K = any, V = any> {
|
|||
*
|
||||
* The above function is an iterator that yields key-value pairs from a linked list.
|
||||
*/
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
let node = this._head;
|
||||
while (node !== this._sentinel) {
|
||||
yield <[K, V]>[node.key, node.value];
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export class TreeMap {}
|
||||
export class TreeMap {
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export class TreeSet {}
|
||||
export class TreeSet {
|
||||
}
|
||||
|
|
|
@ -826,7 +826,7 @@ export class DoublyLinkedList<E = any> {
|
|||
/**
|
||||
* The function returns an iterator that iterates over the values of a linked list.
|
||||
*/
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.head;
|
||||
|
||||
while (current) {
|
||||
|
|
|
@ -773,7 +773,7 @@ export class SinglyLinkedList<E = any> {
|
|||
/**
|
||||
* The function returns an iterator that iterates over the values of a linked list.
|
||||
*/
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.head;
|
||||
|
||||
while (current) {
|
||||
|
|
|
@ -10,7 +10,8 @@ export class Vector2D {
|
|||
public x: number = 0,
|
||||
public y: number = 0,
|
||||
public w: number = 1 // needed for matrix multiplication
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The function checks if the x and y values of a point are both zero.
|
||||
|
|
|
@ -9,7 +9,8 @@ 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
|
||||
export class Deque<E = any> extends DoublyLinkedList<E> {}
|
||||
export class Deque<E = any> extends DoublyLinkedList<E> {
|
||||
}
|
||||
|
||||
// O(1) time complexity of obtaining the value
|
||||
// O(n) time complexity of adding at the beginning and the end
|
||||
|
|
|
@ -300,7 +300,7 @@ export class Queue<E = any> {
|
|||
return new Queue(this.nodes.slice(this.offset));
|
||||
}
|
||||
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
for (const item of this.nodes) {
|
||||
yield item;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
console.error(e);
|
||||
}
|
||||
try {
|
||||
const {AVLTree} = window.dataStructureTyped;
|
||||
const { AVLTree } = window.dataStructureTyped;
|
||||
const avlTree = new AVLTree();
|
||||
const $avlTree = document.createElement('li');
|
||||
const $avlTreeSpan = document.createElement('span');
|
||||
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
|
||||
try {
|
||||
const {BinaryTree} = dataStructureTyped;
|
||||
const { BinaryTree } = dataStructureTyped;
|
||||
const tree = new BinaryTree();
|
||||
tree.add(3);
|
||||
tree.add(12);
|
||||
|
@ -76,8 +76,8 @@
|
|||
|
||||
|
||||
try {
|
||||
const {OrderedMap} = sdsl;
|
||||
const {RedBlackTree} = dataStructureTyped;
|
||||
const { OrderedMap } = sdsl;
|
||||
const { RedBlackTree } = dataStructureTyped;
|
||||
const cTree = new OrderedMap();
|
||||
const tree = new RedBlackTree();
|
||||
const tS = performance.now();
|
||||
|
@ -101,9 +101,9 @@
|
|||
}
|
||||
|
||||
try {
|
||||
const {PriorityQueue: CPriorityQueue} = sdsl;
|
||||
const {PriorityQueue} = dataStructureTyped;
|
||||
const pq = new PriorityQueue({comparator: (a, b) => b - a});
|
||||
const { PriorityQueue: CPriorityQueue } = sdsl;
|
||||
const { PriorityQueue } = dataStructureTyped;
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => b - a });
|
||||
|
||||
const tS = performance.now();
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ class MyGraph<
|
|||
describe('AbstractGraph Operation Test', () => {
|
||||
const myGraph: MyGraph<number, string> = new MyGraph<number, string>();
|
||||
|
||||
beforeEach(() => {});
|
||||
beforeEach(() => {
|
||||
});
|
||||
it('should edge cases', function () {
|
||||
myGraph.addVertex('A', 1);
|
||||
myGraph.addVertex('B', 2);
|
||||
|
|
Loading…
Reference in a new issue