3 ms·
It's a poor choice on the author's part http://doc.rust-lang.org/std/collections/ http://doc.rust-lang.org/std/collections/ Use a HashMap when: -
by euid 12y ago
It's a poor choice on the author's part
http://doc.rust-lang.org/std/collections/ http://doc.rust-lang.org/std/collections/
Use a HashMap when:
- You want to associate arbitrary keys with an arbitrary value.
- You want a cache.
- You want a map, with no extra functionality.
Use a BTreeMap when:
- You're interested in what the smallest or largest key-value pair is.
- You want to find the largest or smallest key that is smaller or larger
than something
- You want to be able to get all of the entries in order on-demand.
- You want a sorted map.
- arthurtw 12y agoI chose it because I wanted to learn Rust by implementing my own BTreeMap struct. I admit it’s not a good choice performance-wise, and made the comparison with Nim less meaningful. I’ve updated the code and article with HashMap. It runs about 6~7% faster than BTreeMap.
- dbaupp 12y agoSlightly confusingly, the authors BTreeMap just appears to be a binary tree, while the standard library BTreeMap is a B-tree: http://en.wikipedia.org/wiki/B-tree http://en.wikipedia.org/wiki/B-tree