Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    ssetpublic

    sset - Sorted Set for javascript

    Yet another sorted set, but with the following feature set:

    • Uses binary-sort to insert and search and insert in set, so it is incredibly fast.
    • Can contain any kind of object
    • You can specify a custom comparator, if you have objects, strings etc (default uses number values)

    Benchmark against array (though an array is not a set) benchmark

    Usage:

    var SortedSet = require('SortedSet');
     
    var set = SortedSet([5,4,2,1]);
     
    set.add(3);
     
    // set will now contain 1, 2, 3, 4, 5 

    Custom comparator

    var set = SortedSet(function(a, b) {
        return a.val - b.val;
    });
     
    set.add({val: 5}, {val: 3});
     
    // set now contains [{val: 3}, {val: 5}]; 

    Installation

    npm install sset
    

    Todo

    Obvious big things missing, namely:

    • things handling other sets:
      • union
      • intersection
    • tests for all functionlity

    License

    MIT

    Keywords

    none

    install

    npm i sset

    Downloadslast 7 days

    8

    version

    0.0.4

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar