mozilla/rust — pull request #14443 by schmee (2014-05-26 12:29:29+00:00)
Title: Add CountedSet to libcollections

This adds a CountedSet heavily inspired by Pythons [collections.Counter](https://docs.python.org/2/library/collections.html#collections.Counter) to Rust (with some differences). This is my first PR to Rust, so I apologize for any mistakes!

There are a couple of outstanding issues I need advice on:
* `elements` should return a FlatMap instead of a Vec, but I need help with how to write the return type for the FlatMap.
* `get` returns 0 for missing elements, to be consistent with Python. But how to handle `get_mut`? Right now it fails with missing elements, but I don't like this asymmetry between `get` and `get_mut`.
* In this version only positive counts are allowed. Should this be generalized to anything with the `Num` trait?
* The `add`, `subtract`, `union` and `intersection` methods return new copies, should these return references instead, like HashSet?