If I needed to hash an entire HashSet<T>
or HashMap<T, U>
, where T
already had some hash algorithm implemented, how would I do it? Note that I am not asking about hashing elements of a hash table, I'm talking about hashing the entire data structure itself. This is not too difficult with an ordered set like a TreeSet
, but because the order of the elements of a hash table is not well-defined, this is more tricky. Sorting the elements is infeasible in the general case, as the algorithm should take no more than O(n) time.
I'm looking for a general, language independent example, but you can provide code or links to code from any language.