Nifty Procrastination Machine

    js-sdsl

    4.0.3 • Public • Published

    js-sdsl logo

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

    Version Build Status Coverage Status GITHUB Star Downloads Rate this package License GITHUB-language

    English | 简体中文

    Included data structures

    • Vector
    • Stack
    • Queue
    • LinkList
    • Deque
    • PriorityQueue
    • OrderedSet (using RBTree)
    • OrderedMap (using RBTree)
    • HashSet
    • HashMap

    Supported platforms

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

    Download

    Download directly

    Or install js-sdsl using npm

    npm install js-sdsl

    Usage

    You can visit our official website to get more information.

    To help you have a better use, we also 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,
          Stack,
          Queue,
          LinkList,
          Deque,
          PriorityQueue,
          OrderedSet,
          OrderedMap,
          HashSet,
          HashMap
        } = sdsl;
        const myOrderedMap = new OrderedMap();
        myOrderedMap.setElement(1, 2);
        console.log(myOrderedMap.getElementByKey(1)); // 2
    </script>

    For npm

    // esModule
    import { OrderedMap } from 'js-sdsl';
    // commonJs
    const { OrderedMap } = require('js-sdsl');
    const myOrderedMap = new OrderedMap();
    myOrderedMap.setElement(1, 2);
    console.log(myOrderedMap.getElementByKey(1)); // 2

    Build by source code

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

    Unit test

    For check

    We use jest library to write unit tests, you can see test coverage on coveralls. You can run yarn test:check command to reproduce it.

    For performance

    We tested most of the functions for efficiency. You can go to testResult.txt to see our running results or reproduce it with yarn test:performance command.

    The following is a partial interception of the performance test:

    =================================== OrderedSet ===================================
    ┌─────────┬─────────────────────┬─────────┬───────────────┬─────────┐
    │ (index) │      testFunc       │ testNum │ containerSize │ runTime │
    ├─────────┼─────────────────────┼─────────┼───────────────┼─────────┤
    │    0    │    'constructor'    │    1    │    1000000    │  2150   │
    │    1    │      'insert'       │ 1000000 │    2000000    │   827   │
    │    2    │ 'eraseElementByKey' │ 1000000 │    3000000    │   505   │
    │    3    │ 'eraseElementByPos' │   10    │    3000000    │  1726   │
    │    4    │       'union'       │    1    │    2999990    │  2362   │
    │    5    │    'lowerBound'     │ 1000000 │    2999990    │  1465   │
    │    6    │    'upperBound'     │ 1000000 │    2999990    │  1524   │
    │    7    │ 'reverseLowerBound' │ 1000000 │    2999990    │  1952   │
    │    8    │ 'reverseUpperBound' │ 1000000 │    2999990    │  1741   │
    └─────────┴─────────────────────┴─────────┴───────────────┴─────────┘
    =================================== OrderedMap ===================================
    ┌─────────┬─────────────────────┬─────────┬───────────────┬─────────┐
    │ (index) │      testFunc       │ testNum │ containerSize │ runTime │
    ├─────────┼─────────────────────┼─────────┼───────────────┼─────────┤
    │    0    │    'constructor'    │    1    │    1000000    │  2180   │
    │    1    │    'setElement'     │ 1000000 │    2000000    │  1242   │
    │    2    │ 'eraseElementByKey' │ 1000000 │    2000000    │   804   │
    │    3    │ 'eraseElementByPos' │   100   │    1000000    │  7191   │
    │    4    │       'union'       │    1    │    1999900    │  2608   │
    │    5    │    'lowerBound'     │ 1000000 │    1999900    │  1502   │
    │    6    │    'upperBound'     │ 1000000 │    1999900    │  1816   │
    │    7    │ 'reverseLowerBound' │ 1000000 │    1999900    │  1640   │
    │    8    │ 'reverseUpperBound' │ 1000000 │    1999900    │  1598   │
    └─────────┴─────────────────────┴─────────┴───────────────┴─────────┘

    Maintainers

    @ZLY201

    Contributing

    Feel free to dive in! Open an issue or submit PRs. It may be helpful to read the Contributor Guide.

    Contributors

    Thanks goes to these wonderful people:


    Takatoshi Kondo

    💻 ⚠️

    This project follows the all-contributors specification. Contributions of any kind welcome!

    License

    MIT © ZLY201

    Install

    npm i js-sdsl

    DownloadsWeekly Downloads

    172,563

    Version

    4.0.3

    License

    MIT

    Unpacked Size

    368 kB

    Total Files

    105

    Last publish

    Collaborators

    • yaozilong