Various data structures for JavaScript - implemented in TypeScript.
npm install containers.jsBasic usage:
``ts`
const c = new SortedArray
c.push(3);
c.push(2);
c.push(5);
c.values(); // [2, 3, 5]
With custom compare function:
`ts`
const c = new SortedArray
if (a === b) {
return 0;
}
return a < b ? 1 : -1;
});
c.insertValues([1, 2, 3, 4]);
c.values(); // [4, 3, 2, 1];
Basic usage:
`ts`
const queue = new UniqueQueue
queue.push(1);
queue.push(2);
queue.push(2);
queue.push(3);
queue.values(); // [3, 2, 1]
With fixed queue-length:
`ts`
const queue = new UniqueQueue
for (let i = 0; i < 10; i++) {
queue.push(i);
}
expect(queue.values()).toEqual([9, 8, 7, 6, 5]);
Setup:
``
yarn
Running tests:
```
$ yarn test