reorganize directory and file structure

This commit is contained in:
Joeri Exelmans 2025-05-07 13:44:49 +02:00
parent 1d826ea8d4
commit 48390b8556
99 changed files with 1155 additions and 1629 deletions

View file

@ -0,0 +1,21 @@
// Tiny wrapper around function-red-black-tree that overrides the [inspect.custom] symbol so when we print it (during debugging) we just see the (key=>value)-pairs instead of the tree structure.
import createRBTree from "functional-red-black-tree";
import { inspect } from "util";
export class RBTreeWrapper {
constructor(tree) {
this.tree = tree;
}
static new(compareFn) {
return new RBTreeWrapper(createRBTree(compareFn))
}
// pretty print to console
[inspect.custom](depth, options, inspect) {
const entries = [];
this.tree.forEach((key, val) => { entries.push(`${inspect(key)} => ${inspect(val)}`); });
return `RBTree(${this.tree.length}) {${entries.join(', ')}}`;
}
}