From 7365f661db8854230d65af708604a81a0aa9d4a7 Mon Sep 17 00:00:00 2001 From: Revone Date: Mon, 4 Dec 2023 22:09:09 +0800 Subject: [PATCH] docs: Snippets of TS --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 73690df..9ecfd30 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ our [visual tool](https://github.com/zrwusa/vivid-algorithm) ```ts import {BST, BSTNode} from 'data-structure-typed'; -const bst = new BST(); +const bst = new BST(); bst.add(11); bst.add(3); bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]); @@ -167,7 +167,7 @@ bst.print() // \ // 7 -const objBST = new BST<{height: number, age: number}>(); +const objBST = new BST(); objBST.add(11, { "name": "Pablo", "age": 15 }); objBST.add(3, { "name": "Kirk", "age": 1 }); @@ -223,7 +223,7 @@ bfsIDs[0] === 11; // true ```ts import {AVLTree} from 'data-structure-typed'; -const avlTree = new AVLTree(); +const avlTree = new AVLTree(); avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) avlTree.isAVLBalanced(); // true avlTree.delete(10); @@ -235,7 +235,7 @@ avlTree.isAVLBalanced(); // true ```ts import {RedBlackTree} from 'data-structure-typed'; -const rbTree = new RedBlackTree(); +const rbTree = new RedBlackTree(); rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) rbTree.isAVLBalanced(); // true rbTree.delete(10); @@ -257,7 +257,7 @@ rbTree.print() ```ts import {DirectedGraph} from 'data-structure-typed'; -const graph = new DirectedGraph(); +const graph = new DirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); @@ -286,7 +286,7 @@ const topologicalOrderKeys = graph.topologicalSort(); // ['A', 'B', 'C'] ```ts import {UndirectedGraph} from 'data-structure-typed'; -const graph = new UndirectedGraph(); +const graph = new UndirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); graph.addVertex('C');