> >> Is there some semantic trouble we would get into by adding an
> >> 'implementsSameMapping' method (feel free to substitute a better name)
> >> to the table protocol?
> >
> >It would be hell on wheels to implement. If you want to do comparisons like
> >that you should be using a binary tree and not a hashtable.
>
> Wouldn't it just be (in pseudocode for two maps, A and B)
>
> if a count != B count
> return false
> foreach k in A keys
> if A[k] != B[k]
> return false
> return true
I may be misunderstanding, but I think your pseudocode implies computing the hash code for every element. This is what I meant by hell to implement. There is no way to do an element by element comparison between two hashtables since two equal hashtables will have different orderings if their underlying array sizes are not equal. Since these array sizes are dependent upon the insert/remove history of the hashtable and not its current content, two equal hashtables very likely do not use the same size of underlying array.
Tyler