Class | Multiset |
In: |
lib/rack/mount/vendor/multimap/multiset.rb
|
Parent: | Set |
Multiset implements a collection of unordered values and allows duplicates.
require 'multiset' s1 = Multiset.new [1, 2] # -> #<Multiset: {1, 2}> s1.add(2) # -> #<Multiset: {1, 2, 2}> s1.merge([2, 6]) # -> #<Multiset: {1, 2, 2, 2, 3}> s1.multiplicity(2) # -> 3 s1.multiplicity(3) # -> 1
Returns a new set containing elements exclusive between the set and the given enumerable object. (set ^ enum) is equivalent to ((set | enum) - (set & enum)).
Calls the given block once for each element in the set, passing the element as parameter. Returns an enumerator if no block is given.
Returns true if two sets are equal. Two multisets are equal if they have the same cardinalities and each element has the same multiplicity in both sets. The equality of each element inside the multiset is defined according to Object#eql?.