Re: How can i implements a class like an HashMap but with 2 keys ?



On Wed, 29 Aug 2007 06:10:46 -0700, Patricia Shanahan wrote:
Roedy Green wrote:
3. concatenate your two String keys into one.

I'd avoid this one unless there is at least one char bit pattern
that cannot appear in the first input, to use as separator.

Why is it necessary to separate them? The cost of not doing so is only
an increased risk of collisions.

In fact that cost might be zero or so negligible that adding the
separator at each operation costs more than the potential collisions
it attempts to avoid.

I'm assuming that the concatenation is only used internally in the
HashMap, and that the separate components are used elsewhere in their
original, separate state.

/gordon

--
.



Relevant Pages