A javascript standard data structure library which benchmark against C++ STL.

Overview

js-sdsl

A javascript standard data structure library which benchmark against C++ STL.

Note

Note that our official version starts from 2.0.0. In order to avoid unnecessary trouble, please select the latest version when downloading (>= 2.0.0).

Unfortunately, I try my best to improve the performance of hash table but failed. Ideally, the hash table should be O(1) and in my project when the size of each bucket is 1, its time is much longer than Set and Map.

After analysis, I find the operator new costs nearly 2s when the size is 1e6, This seems to be the bottleneck of js.

You can try the following code to verify my statement.

console.time("run");
const arr = new Array(1000000);
arr[100000] = new Array();
console.timeEnd("run");

You can imagine what happens when I repeat the above operation many times.

If you want to use hash container in js, please use set or map in ES6.

The official Set and Map are implemented using hash table instead of RBTree.

For more information about js hash table, please refer to https://stackoverflow.com/questions/368280/javascript-hashmap-equivalent.

Included data structures

  • Vector
  • Stack
  • Queue
  • LinkList
  • Deque
  • PriorityQueue
  • Set (using RBTree)
  • Map (using RBTree)
  • HashSet (for reference only)
  • HashMap (for reference only)

Supported platforms

  • node.js (using commonjs)
  • react/vue (using es5)
  • browser (support most browsers including IE8+)

Download

Download directly

Or install js-sdsl using npm

npm install js-sdsl

Usage

To help you have a better use, we provide this API document.

For Browser

<!-- you can download the file locally and import it or import it dynamically by using url. -->
<script src="https://zly201.github.io/js-sdsl/js-sdsl.min.js"></script>
<script>
    const { Vector } = sdsl;
    const myVector = new Vector();
    // you code here...
</script>

Other

Just like other packages.

If you want to get more help, viewing src/test.ts may help.

Build by source code

You can pull this repository and run yarn build to rebuild this library.

Unit test

Before publishing, we conducted strict unit tests on each function, you can see testResult.txt to find our test results or run yarn test to reproduce it.

License

This project is MIT licensed.

You might also like...

A standard library to interact with KaiOS 2.x and 3.x APIs.

kaios-lib A standard library to interact with KaiOS 2.x and 3.x* APIs. * 3.x support coming when there is a good dev device available for testing purp

Jun 3, 2022

The coding-standard for JavaScript projects.

JavaScript Coding Standard A set of ESLint rules applied to all Croct JavaScript projects. 📦 Releases · 🐞 Report Bug · ✨ Request Feature Installatio

Dec 15, 2022

Responsive, auto-saving To-Do List made from scratch using JavaScript only, but refactoring the code into ES6 standard

Project Name ES6 AWESOME BOOKS Website Name AWSM BOOKS Project Website (GitHub Pages) https://github.com/Zeraltz/es6-awsm-books Clone the Project git

Jun 25, 2022

Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values.

@suchipi/is Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values. Usage import { is

Sep 8, 2022

Chrome extension to simulate cryptoblades fights, giving you the win rate % against all enemies with just one click

Chrome extension to simulate cryptoblades fights, giving you the win rate % against all enemies with just one click

CryptoBlades fight simulator This is a Chrome extension that will help you to know the exact win rate percentage you have on each cryptoblades fight.

Aug 7, 2022

On-chain defense against hostile takeovers

Poison pill On-chain defense against hostile takeovers. In layman's terms, this smart contract only facilitates a discounted sale of shares to a white

Jul 19, 2022

Validate directory structure and file contents with an extension of JSON schema.

directory-schema-validator Description Validate directory structure and file contents with an extension of JSON schema. Install Install using NPM or s

Nov 1, 2022

Flipkart Clone using MERN Stack with proper File Structure and also follow MVC architecture. You can view live app.

Flipkart Clone using MERN Stack with proper File Structure and also follow MVC architecture.  You can view live app.

Flipkart Clone MERN APP Dhaval Patel's Flipkart Clone is done with top-notch features for the entrepreneur startups like Flipkart. It has strong authe

Dec 29, 2022

A lightweight extension to automatically detect and provide verbose warnings for embedded iframe elements in order to protect against Browser-In-The-Browser (BITB) attacks.

A lightweight extension to automatically detect and provide verbose warnings for embedded iframe elements in order to protect against Browser-In-The-Browser (BITB) attacks.

Enhanced iFrame Protection - Browser Extension Enhanced iFrame Protection (EIP) is a lightweight extension to automatically detect and provide verbose

Dec 24, 2022
Releases(v4.1.1)
Owner
Zilong Yao
A student from China University of Geosciences (Wuhan).
Zilong Yao
This is a tic-tac-toe game but differs from most others as it carries the option of playing against an AI (COM) or against a friend.

TIC-TAC-TOE This is a simple tic-tac-toe game with the exception of playing against an algorithm or against a friend. At the very start, you have to s

Paul Ibeabuchi C. 4 Jul 2, 2022
Fullstack Dynamic NFT Mini Game built using 💎 Diamond Standard [EIP 2535] 🏃‍♀️Players can use Hero NFT to battle against Thanos ⚔ Heroes can be Healed by staking their NFT 🛡

?? Fullstack Dynamic NFT Mini Game ?? ?? Using Diamond Standard Play On ?? ?? ⏩ http://diamond-dapp.vercel.app/ Project Description ?? Fullstack Dynam

Shiva Shanmuganathan 21 Dec 23, 2022
A large scale simulation which pits millions of space ships against each other in a virtual universe all running directly in SingleStore.

Wasm Space Program In this demo we simulate a fake universe full of thousands of solar systems. In each solar system there are many space ships and en

SingleStore Labs 11 Nov 2, 2022
LeakInspector: an add-on that warns and protects against personal data exfiltration

LeakInspector ?? LeakInspector is an add-on that warns and protects against personal data exfiltration. We developed LeakInspector to help publishers

LeakyForms 119 Nov 15, 2022
Validate your Markdown frontmatter data against a JSON schema — remark-lint rule plugin

remark-lint-frontmatter-schema Validate Markdown frontmatter YAML against an associated JSON schema with this remark-lint rule plugin. Supports: Types

Julian Cataldo 20 Dec 10, 2022
Lazy minting of ERC721 NFTs using EIP712 standard for typed, structured data. ✨

ERC721 - Signature minting Lazy minting of ERC721 NFTs using EIP712 standard for typed, structured data. ✨ How it works Lazy minting or Signature mint

Sunrit Jana 21 Oct 20, 2022
Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum.

Stacks Voice Stacks Voice is a reference project that builds on the SIP018 signed structured data standard to create an accountless internet forum. Th

Clarity Innovation Lab 4 Dec 21, 2022
✨ Standard library for JavaScript and Node.js. ✨

stdlib (/ˈstændərd lɪb/ "standard lib") is a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing appli

stdlib 3.1k Dec 31, 2022
JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

Aykut Saraç 20.6k Jan 4, 2023