A sparse set is a performant, set-like unsigned integer collection, providing O(1) time complexity for addition, deletion, and lookup. Iteration is O(n).
- ECMA Script 2015 (ES6) style API
- Framework agnostic
- TypeScript compatible
npm install https://github.com/gigann/sparse-set-js.git
import SparseSet from 'sparse-set';
let sset = new SparseSet(capacity, maximumValue);
sset.add(1);
sset.delete(1);
sset.has(1);
sset.forEach(e => {
someFunction(e);
});
sset.clear();