|
|
|
|
|
by fnordsensei
3237 days ago
|
|
From what I've read, it seems that the performance benefits disappear when compound data structures/objects are used as keys. Is this true? Let's say that I were to use a vector of coordinates as the key to something in a map. Would CHAMP still vastly outperform HAMT? |
|
To answer your questions about using vectors of coordinates of keys: it depends on the design implementation of the vector's hash code, regardless if you use HAMT or CHAMP.
Using collections as keys in other collections is in general a performance sensitive subject. The available HAMT implementations in Clojure and Scala fail to deliver here. The case study in Chapter 3.7 nests hash-sets into hash-sets (i.e., Set.Immutable<Set.Immutable<K>> sets). The CHAMP implementation yields minimal speedups of ~10x over Clojure and Scala due to the way it calculates and incrementally updates the collection's hash code.