English | 简体中文
- Vector
- Stack
- Queue
- LinkList
- Deque
- PriorityQueue
- OrderedSet (using RBTree)
- OrderedMap (using RBTree)
- HashSet
- HashMap
- node.js (using commonjs)
- react/vue (using es5)
- browser (support most browsers)
Download directly
- js-sdsl.js (for development)
- js-sdsl.min.js (for production)
Or install js-sdsl using npm
npm install js-sdsl
To help you have a better use, we provide this API document.
<!-- 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>
// 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
You can pull this repository and run yarn build
to rebuild this library.
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.
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 │ 1969 │
│ 1 │ 'insert' │ 1000000 │ 2000000 │ 617 │
│ 2 │ 'eraseElementByKey' │ 1000000 │ 3000000 │ 496 │
│ 3 │ 'eraseElementByPos' │ 10 │ 3000000 │ 603 │
│ 4 │ 'union' │ 1 │ 2999990 │ 3531 │
│ 5 │ 'lowerBound' │ 1000000 │ 2999990 │ 1127 │
│ 6 │ 'upperBound' │ 1000000 │ 2999990 │ 1492 │
│ 7 │ 'reverseLowerBound' │ 1000000 │ 2999990 │ 1131 │
│ 8 │ 'reverseUpperBound' │ 1000000 │ 2999990 │ 1143 │
└─────────┴─────────────────────┴─────────┴───────────────┴─────────┘
=================================== OrderedMap ===================================
┌─────────┬─────────────────────┬─────────┬───────────────┬─────────┐
│ (index) │ testFunc │ testNum │ containerSize │ runTime │
├─────────┼─────────────────────┼─────────┼───────────────┼─────────┤
│ 0 │ 'constructor' │ 1 │ 1000000 │ 2259 │
│ 1 │ 'setElement' │ 1000000 │ 2000000 │ 875 │
│ 2 │ 'eraseElementByKey' │ 1000000 │ 2000000 │ 426 │
│ 3 │ 'eraseElementByPos' │ 100 │ 1000000 │ 4722 │
│ 4 │ 'union' │ 1 │ 1999900 │ 5106 │
│ 5 │ 'lowerBound' │ 1000000 │ 1999900 │ 1279 │
│ 6 │ 'upperBound' │ 1000000 │ 1999900 │ 1197 │
│ 7 │ 'reverseLowerBound' │ 1000000 │ 1999900 │ 1222 │
│ 8 │ 'reverseUpperBound' │ 1000000 │ 1999900 │ 1347 │
└─────────┴─────────────────────┴─────────┴───────────────┴─────────┘
Feel free to dive in! Open an issue or submit PRs. It may be helpful to read the Contributor Guide.
Thanks goes to these wonderful people:
Takatoshi Kondo 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © ZLY201