3.15.111 • Published 10 months ago

@erboladaiorg/ad-exercitationem-ducimus v3.15.111

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@erboladaiorg/ad-exercitationem-ducimus

npm GitHub contributors npm package minimized gzipped size (select exports) GitHub top language GITHUB Star eslint NPM npm

Installation and Usage

npm

npm i @erboladaiorg/ad-exercitationem-ducimus --save

yarn

yarn add @erboladaiorg/ad-exercitationem-ducimus
import {
  Heap, Graph, Queue, Deque, PriorityQueue, BST, Trie, DoublyLinkedList,
  AVLTree, SinglyLinkedList, DirectedGraph, RedBlackTree, TreeMultiMap,
  DirectedVertex, Stack, AVLTreeNode
} from '@erboladaiorg/ad-exercitationem-ducimus';

If you only want to use a specific data structure independently, you can install it separately, for example, by running

npm i heap-typed --save

Why

Do you envy C++ with STL (std::), Python with collections, and Java with java.util ? Well, no need to envy anymore! JavaScript and TypeScript now have @erboladaiorg/ad-exercitationem-ducimus.Benchmark compared with C++ STL. API standards aligned with ES6 and Java. Usability is comparable to Python

Performance

Performance surpasses that of native JS/TS

Conciseness and uniformity

In java.utils, you need to memorize a table for all sequential data structures(Queue, Deque, LinkedList),

whereas in our @erboladaiorg/ad-exercitationem-ducimus, you only need to remember four methods: push, pop, shift, and unshift for all sequential data structures(Queue, Deque, DoublyLinkedList, SinglyLinkedList and Array).

Data structures available

We provide data structures that are not available in JS/TS

Vivid Examples

AVL Tree

Try it out, or you can run your own code using our visual tool

npm.io

Tree Multi Map

Try it out

npm.io

Directed Graph

Try it out

npm.io

Map Graph

Try it out

npm.io

Code Snippets

Red Black Tree snippet

TS

import { RedBlackTree } from '@erboladaiorg/ad-exercitationem-ducimus';

const rbTree = new RedBlackTree<number>();
rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
rbTree.isAVLBalanced();    // true
rbTree.delete(10);
rbTree.isAVLBalanced();    // true
rbTree.print()
//         ___6________
//        /            \
//      ___4_       ___11________
//     /     \     /             \
//    _2_    5    _8_       ____14__
//   /   \       /   \     /        \
//   1   3       7   9    12__     15__
//                            \        \
//                           13       16

JS

import { RedBlackTree } from '@erboladaiorg/ad-exercitationem-ducimus';

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);
rbTree.isAVLBalanced();    // true
rbTree.print()
//         ___6________
//        /            \
//      ___4_       ___11________
//     /     \     /             \
//    _2_    5    _8_       ____14__
//   /   \       /   \     /        \
//   1   3       7   9    12__     15__
//                            \        \
//                           13       16

Free conversion between data structures.

const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
const orgStrArr = ["trie", "trial", "trick", "trip", "tree", "trend", "triangle", "track", "trace", "transmit"];
const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]];

const queue = new Queue(orgArr);
queue.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]

const deque = new Deque(orgArr);
deque.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]

const sList = new SinglyLinkedList(orgArr);
sList.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]

const dList = new DoublyLinkedList(orgArr);
dList.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]

const stack = new Stack(orgArr);
stack.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]

const minHeap = new MinHeap(orgArr);
minHeap.print();
// [1, 5, 2, 7, 6, 3, 4, 9, 8]

const maxPQ = new MaxPriorityQueue(orgArr);
maxPQ.print();
// [9, 8, 4, 7, 5, 2, 3, 1, 6]

const biTree = new BinaryTree(entries);
biTree.print();
//         ___6___
//        /       \
//     ___1_     _2_
//    /     \   /   \
//   _7_    5   3   4
//  /   \
//  9   8

const bst = new BST(entries);
bst.print();
//     _____5___
//    /         \
//   _2_       _7_
//  /   \     /   \
//  1   3_    6   8_
//        \         \
//        4         9


const rbTree = new RedBlackTree(entries);
rbTree.print();
//     ___4___
//    /       \
//   _2_     _6___
//  /   \   /     \
//  1   3   5    _8_
//              /   \
//              7   9


const avl = new AVLTree(entries);
avl.print();
//     ___4___
//    /       \
//   _2_     _6___
//  /   \   /     \
//  1   3   5    _8_
//              /   \
//              7   9

const treeMulti = new TreeMultiMap(entries);
treeMulti.print();
//     ___4___
//    /       \
//   _2_     _6___
//  /   \   /     \
//  1   3   5    _8_
//              /   \
//              7   9

const hm = new HashMap(entries);
hm.print()
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]

const rbTreeH = new RedBlackTree(hm);
rbTreeH.print();
//     ___4___
//    /       \
//   _2_     _6___
//  /   \   /     \
//  1   3   5    _8_
//              /   \
//              7   9

const pq = new MinPriorityQueue(orgArr);
pq.print();
// [1, 5, 2, 7, 6, 3, 4, 9, 8]

const bst1 = new BST(pq);
bst1.print();
//     _____5___
//    /         \
//   _2_       _7_
//  /   \     /   \
//  1   3_    6   8_
//        \         \
//        4         9

const dq1 = new Deque(orgArr);
dq1.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const rbTree1 = new RedBlackTree(dq1);
rbTree1.print();
//    _____5___
//   /         \
//  _2___     _7___
// /     \   /     \
// 1    _4   6    _9
//      /         /
//      3         8


const trie2 = new Trie(orgStrArr);
trie2.print();
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) });
heap2.print();
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
const dq2 = new Deque(heap2);
dq2.print();
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
const entries2 = dq2.map((el, i) => [i, el]);
const avl2 = new AVLTree(entries2);
avl2.print();
//     ___3_______
//    /           \
//   _1_       ___7_
//  /   \     /     \
//  0   2    _5_    8_
//          /   \     \
//          4   6     9

Binary Search Tree (BST) snippet

import { BST, BSTNode } from '@erboladaiorg/ad-exercitationem-ducimus';

const bst = new BST<number>();
bst.add(11);
bst.add(3);
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
bst.size === 16;                // true
bst.has(6);                     // true
const node6 = bst.getNode(6);   // BSTNode
bst.getHeight(6) === 2;         // true
bst.getHeight() === 5;          // true
bst.getDepth(6) === 3;          // true

bst.getLeftMost()?.key === 1;   // true

bst.delete(6);
bst.get(6);                     // undefined
bst.isAVLBalanced();            // true
bst.bfs()[0] === 11;            // true
bst.print()
//       ______________11_____           
//      /                     \          
//   ___3_______            _13_____
//  /           \          /        \    
//  1_     _____8____     12      _15__
//    \   /          \           /     \ 
//    2   4_       _10          14    16
//          \     /                      
//          5_    9
//            \                          
//            7

const objBST = new BST<number, { height: number, age: number }>();

objBST.add(11, { "name": "Pablo", "age": 15 });
objBST.add(3, { "name": "Kirk", "age": 1 });

objBST.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5], [
    { "name": "Alice", "age": 15 },
    { "name": "Bob", "age": 1 },
    { "name": "Charlie", "age": 8 },
    { "name": "David", "age": 13 },
    { "name": "Emma", "age": 16 },
    { "name": "Frank", "age": 2 },
    { "name": "Grace", "age": 6 },
    { "name": "Hannah", "age": 9 },
    { "name": "Isaac", "age": 12 },
    { "name": "Jack", "age": 14 },
    { "name": "Katie", "age": 4 },
    { "name": "Liam", "age": 7 },
    { "name": "Mia", "age": 10 },
    { "name": "Noah", "age": 5 }
  ]
);

objBST.delete(11);

AVLTree snippet

import { AVLTree } from '@erboladaiorg/ad-exercitationem-ducimus';

const avlTree = new AVLTree<number>();
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
avlTree.isAVLBalanced();    // true
avlTree.delete(10);
avlTree.isAVLBalanced();    // true

Directed Graph simple snippet

import { DirectedGraph } from '@erboladaiorg/ad-exercitationem-ducimus';

const graph = new DirectedGraph<string>();

graph.addVertex('A');
graph.addVertex('B');

graph.hasVertex('A');       // true
graph.hasVertex('B');       // true
graph.hasVertex('C');       // false

graph.addEdge('A', 'B');
graph.hasEdge('A', 'B');    // true
graph.hasEdge('B', 'A');    // false

graph.deleteEdgeSrcToDest('A', 'B');
graph.hasEdge('A', 'B');    // false

graph.addVertex('C');

graph.addEdge('A', 'B');
graph.addEdge('B', 'C');

const topologicalOrderKeys = graph.topologicalSort(); // ['A', 'B', 'C']

Undirected Graph snippet

import { UndirectedGraph } from '@erboladaiorg/ad-exercitationem-ducimus';

const graph = new UndirectedGraph<string>();
graph.addVertex('A');
graph.addVertex('B');
graph.addVertex('C');
graph.addVertex('D');
graph.deleteVertex('C');
graph.addEdge('A', 'B');
graph.addEdge('B', 'D');

const dijkstraResult = graph.dijkstra('A');
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', 'D']

API docs & Examples

API Docs

Live Examples

Examples Repository

Benchmark

MacBook Pro (15-inch, 2018)

Processor 2.2 GHz 6-Core Intel Core i7

Memory 16 GB 2400 MHz DDR4

Graphics Radeon Pro 555X 4 GB

Intel UHD Graphics 630 1536 MB

macOS Big Sur

Version 11.7.9

The corresponding relationships between data structures in different language standard libraries.

Built-in classic algorithms

Software Engineering Design Standards

We strictly adhere to computer science theory and software development standards. Our LinkedList is designed in the traditional sense of the LinkedList data structure, and we refrain from substituting it with a Deque solely for the purpose of showcasing performance test data. However, we have also implemented a Deque based on a dynamic array concurrently.

supported module system

Now you can use it in Node.js and browser environments

CommonJS:require export.modules =

ESModule:   import export

Typescript:   import export

UMD:           var Deque = dataStructureTyped.Deque

CDN

Copy the line below into the head tag in an HTML document.

development

<script src='https://cdn.jsdelivr.net/npm/@erboladaiorg/ad-exercitationem-ducimus/dist/umd/@erboladaiorg/ad-exercitationem-ducimus.js'></script>

production

<script src='https://cdn.jsdelivr.net/npm/@erboladaiorg/ad-exercitationem-ducimus/dist/umd/@erboladaiorg/ad-exercitationem-ducimus.min.js'></script>

Copy the code below into the script tag of your HTML, and you're good to go with your development.

const { Heap } = dataStructureTyped;
const {
  BinaryTree, Graph, Queue, Stack, PriorityQueue, BST, Trie, DoublyLinkedList,
  AVLTree, MinHeap, SinglyLinkedList, DirectedGraph, TreeMultiMap,
  DirectedVertex, AVLTreeNode
} = dataStructureTyped;
invariantfastcss lessfinduplessindicatorES2020matchInt8ArraybyteschemahasmodulepasswordapollomapreduceupweaksetconcatqueuejsdomwatchertrimEndquotedeleteArray.prototype.filtergdprwaitargvparserfromwatcheslint-pluginparseclientdomES3urlwatchinga11yinternal slotWeakMapECMAScript 6workflowqueueMicrotaskdependency managersidefssorteddatastructureObject.keysES7eventsgraphqltslibReactiveExtensionsfast-copytapecolorcodestypeofresolveArray.prototype.flatMapshamfull-widthlook-upvariablesInt16Arrayreducerloadbalancingless compilercssArray.prototype.findLastjasmineassertiones6preprocessorfast-deep-copystyleguidemovees8nested csssortreact-testing-library[[Prototype]]workerobjecthookshookformregulartestbyteLengthtakerfc4122bundlerprettystatelessES2018fseventssetpackage managerpromisespicomatchdeep-copysymlinkexpressdebugRFC-6455fetch0postcss-plugindeepcloneMicrosoftmakeaccessibilityTypeScriptkeysschemeArrayBuffer#sliceTypeBoxstringifierec2readenvenderclassesqsiteratorhashclassnamesymbolsroute53ES2015es2015checkbootstrap lesscontainsefficientlibphonenumberreuseairbnbmruconnectcss variablemergelimitedworkspace:*middlewarextermwalkfiglethasOwnPropertylanguagesettingsFloat32Arrayisdescriptionnodecryptfind-upESnexttypeerrornodejscommandercolumnsjestshebangsetPrototypeOfscheme-validationlintregexpauthglaciertypedarraypropertycompilertc39pathimportinstallerECMAScript 2016stylebootstrap cssintrinsicless.jsprototypetrimStarttimenameonceutilitiescommandjsObservableemrerroridoutputcharacterses-shim APIchromiumbusycore-jsbluebirdwebObservablesfastifysharedarraybufferObject.fromEntriespackage.jsonStyleSheetInt32ArraydropcallbackiterationeventDispatchersafeformattingstylingshrinkwrapecmascriptqueryimmutablepostcssprotobufstructuredCloneECMAScript 2022dom-testing-librarymobilekinesisfindrequire__proto__dataviewes2016toSortedspinnernopeArray.prototype.flatzodpatchArray.prototype.includesES2022mimeArrayBufferoptimistcolorsenvironmentextensiones7iterateprivateextraexecfunctiontyped arrayspinnersautoscalingestree
@erboladaiorg/adipisci-repellendus-corporis@erboladaiorg/adipisci-aspernatur-explicabo@erboladaiorg/alias-iure@erboladaiorg/blanditiis-facere@erboladaiorg/consectetur-incidunt-a@erboladaiorg/cupiditate-ab@erboladaiorg/eligendi-reiciendis-id@erboladaiorg/molestias-omnis-commodi@erboladaiorg/molestias-repellat@erboladaiorg/quibusdam-autem@erboladaiorg/qui-nostrum-quo@erboladaiorg/quibusdam-ipsa@erboladaiorg/quia-maiores@erboladaiorg/reiciendis-inventore@erboladaiorg/vel-culpa@erboladaiorg/vero-fuga@erboladaiorg/ut-excepturi-dolore@erboladaiorg/velit-corporis-maiores@erboladaiorg/velit-adipisci-dicta@erboladaiorg/animi-dignissimos@erboladaiorg/aliquid-quis-voluptates@erboladaiorg/aliquid-rerum-nam@erboladaiorg/id-qui@erboladaiorg/illum-illum@erboladaiorg/impedit-ipsum-natus@erboladaiorg/illo-dolor-ipsam@erboladaiorg/impedit-ratione-quasi@erboladaiorg/laboriosam-inventore-natus@erboladaiorg/natus-harum-voluptatum@erboladaiorg/natus-illo-iste@erboladaiorg/necessitatibus-pariatur-sint@erboladaiorg/odio-libero-mollitia@erboladaiorg/odio-repellendus-doloremque@erboladaiorg/sed-eligendi-accusantium@erboladaiorg/sapiente-molestiae@erboladaiorg/tenetur-magnam@erboladaiorg/tenetur-magni-ab@erboladaiorg/consequuntur-assumenda@erboladaiorg/dolorum-velit@erboladaiorg/et-placeat@erboladaiorg/et-minus@erboladaiorg/iusto-sit-quasi@erboladaiorg/molestiae-voluptatibus@erboladaiorg/nesciunt-quas-saepe@erboladaiorg/possimus-praesentium-sint@erboladaiorg/quidem-molestiae@erboladaiorg/rem-quisquam-quasi@erboladaiorg/tempora-nisi@erboladaiorg/tempora-quas@erboladaiorg/vitae-aut@erboladaiorg/voluptate-alias-voluptate@erboladaiorg/aliquid-quasi@erboladaiorg/aliquid-impedit@erboladaiorg/corporis-error@erboladaiorg/cum-commodi-consequatur@erboladaiorg/cumque-possimus-delectus@erboladaiorg/doloribus-quos-officia@erboladaiorg/error-expedita-alias@erboladaiorg/esse-esse@erboladaiorg/perspiciatis-error-reprehenderit@erboladaiorg/officiis-maiores@erboladaiorg/placeat-natus@erboladaiorg/quaerat-excepturi@erboladaiorg/quod-id@erboladaiorg/tempore-illo@erboladaiorg/temporibus-eligendi@erboladaiorg/voluptatem-eius@erboladaiorg/voluptates-nisi-quibusdam@erboladaiorg/voluptatibus-beatae@erboladaiorg/dignissimos-ducimus-perferendis@erboladaiorg/deserunt-eos-eum@erboladaiorg/deserunt-nobis@erboladaiorg/expedita-accusantium-nisi@erboladaiorg/in-accusamus-architecto@erboladaiorg/incidunt-dicta-magnam@erboladaiorg/nisi-id-consequatur@erboladaiorg/unde-sit@erboladaiorg/ut-dignissimos-laborum@erboladaiorg/distinctio-illum-harum@erboladaiorg/distinctio-provident-voluptatem@erboladaiorg/dolor-pariatur-modi@erboladaiorg/eaque-eaque-saepe@erboladaiorg/ducimus-necessitatibus-omnis@erboladaiorg/ea-saepe@erboladaiorg/itaque-incidunt-quis@erboladaiorg/libero-a@erboladaiorg/libero-possimus@erboladaiorg/magnam-cumque-non@erboladaiorg/porro-laboriosam@erboladaiorg/quas-officiis@erboladaiorg/quam-id-itaque@erboladaiorg/quod-nesciunt-cum@erboladaiorg/totam-mollitia-tenetur@erboladaiorg/assumenda-cupiditate@erboladaiorg/facere-maxime@erboladaiorg/fugiat-deleniti-repudiandae@erboladaiorg/itaque-quo@erboladaiorg/nesciunt-illum-sunt@erboladaiorg/nesciunt-molestiae-quibusdam@erboladaiorg/non-repellat
3.9.59

1 year ago

3.4.40

1 year ago

3.13.89

11 months ago

2.3.27

1 year ago

2.3.24

1 year ago

2.3.23

1 year ago

2.3.26

1 year ago

2.3.25

1 year ago

2.3.20

1 year ago

2.3.22

1 year ago

2.3.21

1 year ago

3.7.48

1 year ago

3.7.49

1 year ago

3.7.47

1 year ago

3.9.68

12 months ago

3.9.69

12 months ago

3.9.66

12 months ago

3.9.67

12 months ago

3.13.98

11 months ago

3.13.99

11 months ago

3.13.90

11 months ago

3.13.91

11 months ago

3.13.92

11 months ago

3.13.93

11 months ago

3.13.94

11 months ago

3.13.95

11 months ago

3.13.96

11 months ago

3.13.97

11 months ago

3.9.64

12 months ago

3.9.65

12 months ago

3.9.62

12 months ago

3.9.63

12 months ago

3.9.60

1 year ago

3.9.61

12 months ago

3.6.47

1 year ago

3.6.46

1 year ago

3.6.45

1 year ago

3.6.44

1 year ago

3.15.111

10 months ago

3.15.110

10 months ago

3.4.36

1 year ago

3.4.37

1 year ago

3.4.38

1 year ago

3.4.39

1 year ago

3.10.84

11 months ago

3.15.109

10 months ago

3.15.108

10 months ago

3.4.33

1 year ago

3.4.34

1 year ago

3.4.35

1 year ago

2.4.29

1 year ago

2.4.28

1 year ago

3.10.82

11 months ago

3.10.83

11 months ago

2.4.27

1 year ago

3.14.99

11 months ago

2.4.32

1 year ago

2.4.31

1 year ago

2.4.33

1 year ago

2.4.30

1 year ago

3.8.58

1 year ago

3.8.59

1 year ago

3.8.56

1 year ago

3.8.57

1 year ago

3.8.54

1 year ago

3.8.55

1 year ago

3.12.87

11 months ago

3.12.86

11 months ago

3.12.89

11 months ago

3.12.88

11 months ago

3.12.85

11 months ago

3.8.52

1 year ago

3.8.53

1 year ago

3.8.51

1 year ago

3.9.79

12 months ago

3.9.77

12 months ago

3.9.78

12 months ago

3.11.85

11 months ago

3.11.84

11 months ago

3.9.75

12 months ago

3.7.51

1 year ago

3.9.76

12 months ago

3.9.73

12 months ago

3.9.74

12 months ago

3.7.50

1 year ago

3.9.71

12 months ago

3.9.72

12 months ago

3.9.70

12 months ago

3.5.44

1 year ago

3.5.43

1 year ago

3.5.42

1 year ago

3.5.41

1 year ago

3.5.40

1 year ago

3.14.104

11 months ago

2.3.17

1 year ago

3.14.103

11 months ago

2.3.16

1 year ago

3.14.106

10 months ago

2.3.19

1 year ago

3.14.105

11 months ago

2.3.18

1 year ago

3.14.100

11 months ago

2.3.13

1 year ago

2.3.12

1 year ago

3.14.102

11 months ago

2.3.15

1 year ago

3.14.101

11 months ago

2.3.14

1 year ago

3.14.108

10 months ago

3.9.82

11 months ago

3.14.107

10 months ago

3.9.80

12 months ago

3.9.81

11 months ago

2.2.12

1 year ago

2.2.11

1 year ago

1.2.9

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago