maps module introduces two more map data structures to the mix:
HashMap, a map implementation using an array and a hash function. Runtime
TreeMap, a map implementation that uses a self-balanced BinarySearchTree. Runtime
HashMap is more time-efficient, whereas a
TreeMap is more space-efficient. The keys
TreeMap are always sorted. This may or may not be the implementation detail in
TreeMap offers some statistical data, such as maximum/minimum value, median,
range of keys etc., for "free".
HashMap does not.
TreeMap guarantees an
O(logn) search complexity.
HashMap offers an average complexity
O(1) but in the rare case of a rehash, it would take
(static) HashMap :HashMap
(static) TreeMap :TreeMap