1.2.0 • Published 8 years ago

binary-sorted-set v1.2.0

Weekly downloads
64
License
MIT
Repository
github
Last release
8 years ago

binary-sorted-set

keep a set of objects in order.

example

var BinarySortedSet = require('binary-sorted-set')

//pass in a compare function (same as Array#sort)
var set = BinarySortedSet(compare)
set.add(object)
set.rm(object)

//take a range as an array.
console.log(set.range({gt: obj1, lt: obj2}))

api

BinarySortedSet(compare(a, b) => -1|0|1))

construct a new instance of a BinarySortedSet. The compare function must take two set items and return -1 if a < b, 1 if a > b and 0 if they are equal (i.e. the same as Array#sort)

bss.add(item)

add an item to the set.

bss.rm(item)

remove an item from the set.

bss.has(item)

check if an item is in the set.

bss.range({gt, gte, lt, lte})

take a range from within the set, using levelup style ranges.

License

MIT