chore: reformat codebase

This commit is contained in:
Revone 2023-11-20 19:27:25 +08:00
parent d6e186a884
commit 7e3aeb8d2a
5 changed files with 20 additions and 20 deletions

View file

@ -106,7 +106,7 @@ export class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = 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;

View file

@ -3,12 +3,12 @@
<head>
<meta charset='UTF-8'>
<title>CDN Test</title>
<script src="../../dist/umd/data-structure-typed.min.js"></script>
<!-- <script src="../../dist/umd/data-structure-typed.js"></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.42.2/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.43.3/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.44.0/dist/umd/data-structure-typed.min.js'></script>-->
<script src="../../dist/umd/data-structure-typed.min.js"></script>
<!-- <script src="../../dist/umd/data-structure-typed.js"></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.42.2/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.43.3/dist/umd/data-structure-typed.min.js'></script>-->
<!-- <script src='https://cdn.jsdelivr.net/npm/data-structure-typed@1.44.0/dist/umd/data-structure-typed.min.js'></script>-->
<script src='https://unpkg.com/js-sdsl@4.4.2/dist/umd/js-sdsl.js'></script>
</head>
@ -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);

View file

@ -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;

View file

@ -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)

View file

@ -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);