mauriciosantos / Buckets-JS

A complete, fully tested and documented data structure library written in pure JavaScript.
MIT License
1.25k stars 112 forks source link

feature Bag1 <= Bag2 #7

Closed jeromew closed 10 years ago

jeromew commented 10 years ago

Hello,

is there an easy way to test for inclusion of a Bag inside another Bag with buckets ? By inclusion I mean nCopies <= nCopies for each keys ?

Thanks

mauriciosantos commented 10 years ago

Hello,

bag1.forEach( function(element) {
    if( bag1.count(element) <= bag2.count(element) ) {
        // ...
    }
});

I hope it helps you. Mauricio