big-sparse-array
A sparse array optimised for low memory whilst still being fast
Last updated 4 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install big-sparse-array 
SYNC missed versions from official npm registry.

big-sparse-array

A sparse array optimised for low memory whilst still being fast.

npm install big-sparse-array

Uses a shallow tree structure with a branching factor of 4096 to index a series of small arrays that try to compress as much as possible to reduce the memory overhead needed.

Similar to a Map, except it is faster, but might use a bit more memory, ymmv.

Usage

const BigSparseArray = require('big-sparse-array')

const b = new BigSparseArray()

b.set(42422242525, true)
b.get(42422242525) // returns true
b.get(111111111) // returns undefined

API

const b = new BigSparseArray()

Make a new sparse array.

b.set(index, value)

Insert a new value at an index. index must be a integer.

value = b.get(index)

Get a value out. Returns undefined if the value could not be found.

License

MIT

Current Tags

  • 1.0.3                                ...           latest (2 years ago)

4 Versions

  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |