From 7e3aeb8d2a3cb7e24c959c2c690d3d16c11b14f6 Mon Sep 17 00:00:00 2001 From: Revone Date: Mon, 20 Nov 2023 19:27:25 +0800 Subject: [PATCH] chore: reformat codebase --- src/data-structures/binary-tree/rb-tree.ts | 2 +- test/integration/index.html | 20 +++++++++---------- .../comparison/comparison.test.ts | 10 +++++----- .../data-structures/hash/hash-map.test.ts | 6 +++--- .../binary-tree/rb-tree.test.ts | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/data-structures/binary-tree/rb-tree.ts b/src/data-structures/binary-tree/rb-tree.ts index 95f317d..887f83a 100644 --- a/src/data-structures/binary-tree/rb-tree.ts +++ b/src/data-structures/binary-tree/rb-tree.ts @@ -106,7 +106,7 @@ export class RedBlackTree = RedBlackTr if (x) { if (node.key < x.key) { x = x.left; - } else if (node.key > x.key){ + } else if (node.key > x.key) { x = x?.right; } else { return; diff --git a/test/integration/index.html b/test/integration/index.html index 8e75a23..28cf505 100644 --- a/test/integration/index.html +++ b/test/integration/index.html @@ -3,12 +3,12 @@ CDN Test - - - - - - + + + + + + @@ -85,7 +85,7 @@ try { const { OrderedMap } = sdsl; - const { RedBlackTree, AVLTree} = dataStructureTyped; + const { RedBlackTree, AVLTree } = dataStructureTyped; const cRBTree = new OrderedMap(); const rbTree = new RedBlackTree(); const tS = performance.now(); @@ -99,7 +99,7 @@ for (let i = 1; i < 100000; i++) { cRBTree.setElement(i, i); } - console.log(`CRedBlackTree ${n} add`,performance.now() - cS); + console.log(`CRedBlackTree ${n} add`, performance.now() - cS); console.log(cRBTree.size()); // console.log(tree.isPerfectlyBalanced()); @@ -123,7 +123,7 @@ for (let i = 0; i < n; i++) { pq.pop(); } - console.log(`PriorityQueue ${n} add`,performance.now() - tS); + console.log(`PriorityQueue ${n} add`, performance.now() - tS); console.log(pq.size); const cS = performance.now(); const cpq = new CPriorityQueue(); @@ -135,7 +135,7 @@ for (let i = 0; i < n; i++) { cpq.pop(); } - console.log(`CPriorityQueue ${n} add`,performance.now() - cS); + console.log(`CPriorityQueue ${n} add`, performance.now() - cS); console.log(cpq.size()); } catch (e) { console.error(e); diff --git a/test/performance/data-structures/comparison/comparison.test.ts b/test/performance/data-structures/comparison/comparison.test.ts index 701881b..ab1acb5 100644 --- a/test/performance/data-structures/comparison/comparison.test.ts +++ b/test/performance/data-structures/comparison/comparison.test.ts @@ -1,6 +1,6 @@ -import { PriorityQueue as MJSPriorityQueue } from '../../../dist/cjs'; -import { PriorityQueue as SRCPriorityQueue } from '../../../src'; -import { PriorityQueue as CJSPriorityQueue } from '../../../dist/mjs'; +import { PriorityQueue as MJSPriorityQueue } from '../../../../dist/cjs'; +import { PriorityQueue as SRCPriorityQueue } from '../../../../src'; +import { PriorityQueue as CJSPriorityQueue } from '../../../../dist/mjs'; import { Deque as CDeque, HashMap as CHashMap, @@ -12,8 +12,8 @@ import { } from 'js-sdsl'; import * as Benchmark from 'benchmark'; -import { getRandomIntArray, magnitude } from '../../utils'; -import { isCompetitor } from '../../config'; +import { getRandomIntArray, magnitude } from '../../../utils'; +import { isCompetitor } from '../../../config'; const suite = new Benchmark.Suite(); const { TEN_THOUSAND, HUNDRED_THOUSAND, LINEAR } = magnitude; diff --git a/test/performance/data-structures/hash/hash-map.test.ts b/test/performance/data-structures/hash/hash-map.test.ts index 6536a41..40a35dd 100644 --- a/test/performance/data-structures/hash/hash-map.test.ts +++ b/test/performance/data-structures/hash/hash-map.test.ts @@ -83,7 +83,7 @@ suite.add(`${MILLION.toLocaleString()} Set add & has`, () => { suite.add(`${MILLION.toLocaleString()} ObjKey set & get`, () => { const hm = new HashMap<[number, number], number>(); - const objKeys:[number, number][] = []; + const objKeys: [number, number][] = []; for (let i = 0; i < MILLION; i++) { const obj: [number, number] = [i, i]; objKeys.push(obj) @@ -96,7 +96,7 @@ suite.add(`${MILLION.toLocaleString()} ObjKey set & get`, () => { suite.add(`${MILLION.toLocaleString()} Map ObjKey set & get`, () => { const hm = new Map<[number, number], number>(); - const objs:[number, number][] = []; + const objs: [number, number][] = []; for (let i = 0; i < MILLION; i++) { const obj: [number, number] = [i, i]; objs.push(obj) @@ -109,7 +109,7 @@ suite.add(`${MILLION.toLocaleString()} Map ObjKey set & get`, () => { suite.add(`${MILLION.toLocaleString()} Set ObjKey add & has`, () => { const hs = new Set<[number, number]>(); - const objs:[number, number][] = []; + const objs: [number, number][] = []; for (let i = 0; i < MILLION; i++) { const obj: [number, number] = [i, i]; objs.push(obj) diff --git a/test/unit/data-structures/binary-tree/rb-tree.test.ts b/test/unit/data-structures/binary-tree/rb-tree.test.ts index eb13e21..a644bdf 100644 --- a/test/unit/data-structures/binary-tree/rb-tree.test.ts +++ b/test/unit/data-structures/binary-tree/rb-tree.test.ts @@ -489,7 +489,7 @@ describe('RedBlackTree', () => { }); it('duplicates', () => { - tree.addMany([9,8,7,8,8,8,2,3,6,5,5,4]); + tree.addMany([9, 8, 7, 8, 8, 8, 2, 3, 6, 5, 5, 4]); tree.print(); expect(tree.size).toBe(8);