0.0.2 • Published 10 years ago
hashset-native v0.0.2
node-hashset
Provides a native hashset implementation for node.
Often, when you need to use a set in JavaScript, you may instead use a JavaScript object like so:
var cache = {};
cache['foobar'] = true;
if (!cache['foobar']) {
...
}
This works good for up to a few million items, but then it starts to grind v8 down to a halt.
node-hashset implements a stricly typed hashset with std::unsorted_map to enable high-volume sets.
Installation
$ npm install hashset-native
Quick start
var HashSet = require('hashset-native');
var set = new HashSet.string();
set.add('foobar');
Checkout the tests for more examples.
HashSet
There are currently two HashSet constructors, HashSet.int32
and HashSet.string
.
add(value)
Adds value
to the set.
contains(value)
Returns a boolean value indicating if the set contains value
.
remove(value)
Removes value
from the set.
clear()
Removes all values from the set.
size()
Returns the numbers of values in the set.