hashset-native
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "hashset-native", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Native hashset for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -17,5 +17,5 @@ node-hashset | ||
This works good for up to a few million items, but then it starts to grind v8 down to a halt. | ||
This works well for up to a few million items, but after that it starts to grind v8 down to a halt. | ||
node-hashset implements a stricly typed hashset with [std::unsorted_map](http://en.cppreference.com/w/cpp/container/unordered_map) to enable high-volume sets. | ||
node-hashset implements a stricly typed hashset with [std::unsorted_set](http://en.cppreference.com/w/cpp/container/unordered_set) to enable working with extremely large sets. | ||
@@ -50,2 +50,14 @@ ## Installation | ||
### iterator() | ||
Returns an iterator to iterate over the values in the set. | ||
```javascript | ||
var it = set.iterator(); | ||
while (it.hasNext()) { | ||
console.log(it.next()); | ||
} | ||
``` | ||
### remove(value) | ||
@@ -52,0 +64,0 @@ |
@@ -7,9 +7,10 @@ 'use strict'; | ||
[ | ||
{ type: 'string', key1: 'key1', key2: 'key2', missing: 'invalid' }, | ||
{ type: 'int32', key1: -13, key2: 79, missing: 42 } | ||
{ type: 'string', keys: ['key1', 'key2', 'invalid'] }, | ||
{ type: 'int32', keys: [-13, 79, 42] } | ||
].forEach(function (it) { | ||
var type = it.type; | ||
var key1 = it.key1; | ||
var key2 = it.key2; | ||
var missing = it.missing; | ||
var keys = it.keys; | ||
var key1 = it.keys[0]; | ||
var key2 = it.keys[1]; | ||
var missing = it.keys[2]; | ||
@@ -57,3 +58,18 @@ suite('hashset-' + type, function() { | ||
}); | ||
test('iterator()', function () { | ||
set.add(key1); | ||
set.add(key2); | ||
var it = set.iterator(); | ||
assert(it.hasNext()); | ||
assert(keys.indexOf(it.next()) !== -1); | ||
assert(it.hasNext()); | ||
assert(keys.indexOf(it.next()) !== -1); | ||
assert(!it.hasNext()); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
11474
60
72