Quantcast
Channel: Jerry Zitao Liu
Viewing all articles
Browse latest Browse all 41

Multiset

$
0
0

In mathematics, a multiset (or bag) is a generalization of the concept of a set that, unlike a set, allows multiple instances of the multiset’s elements.

A multiset is similar to the set concept but with extra relaxation: allowing duplicate elements. For example, {a, a, b} is not a valid set but is a multiset.

Usually, for each element, we keep not only the value of the element itself, but also the occurrence of the element. For example, a multiset like {a, a, b} is usually stored as {a:2, b:1}.

Google’s Guava has the implementation for multiseet ready to use. https://github.com/google/guava

The implementation is straight forward and has the same idea with what I mentioned above.


Viewing all articles
Browse latest Browse all 41

Trending Articles