hash-unordered-coll computes a collection hash without depending on element order. Use it when equivalent unordered collections must produce the same hash, including collections used as associative keys. section 6.6
Listing 6.6. → Hashing function
(hash [x]) (hash-ordered-coll [coll]) (hash-unordered-coll [coll]) (mix-collection-hash [hash-basis count])
The related hashing API lists hash-unordered-coll alongside hash-ordered-coll and mix-collection-hash. section 6.6
Order does not affect the result
(= (hash-unordered-coll [1 2 3]) (hash-unordered-coll [3 2 1]) (hash-unordered-coll #{1 2 3})) ;; true By contrast, hash-ordered-coll distinguishes these orderings. section 6.6
The function’s contract is compact:
- Accepts one coll argument implementing java.lang.Iterable. section 6.6
- Returns a java.lang.Long in the signed 32-bit integer range. section 6.6
- Throws NullPointerException for nil and ClassCastException for non-Iterable values. section 6.6
