Customizing Hashtable, question 2

  • Thread starter Thread starter Philipp Schumann
  • Start date Start date
P

Philipp Schumann

Hi,

does anyone know whether the custom IComparer and IHashCodeProvider are used
for (a) keys only, (b) values only, (c) both?

(I'd prefer c to be the answer :)

Thanks,
Phil
 
Philipp Schumann said:
does anyone know whether the custom IComparer and IHashCodeProvider are used
for (a) keys only, (b) values only, (c) both?

(I'd prefer c to be the answer :)

a) - the values are never compared in a Hashtable. The point is to map
keys to values.
 
Hi Jon,

thanks---I was just wondering whether Hashtable.ContainsValue would
implicitly use one of the two, or both, thus I was hoping for (c) =)

Best,
Phil
 
Philipp Schumann said:
thanks---I was just wondering whether Hashtable.ContainsValue would
implicitly use one of the two, or both, thus I was hoping for (c) =)

Hashtable.ContainsValue has to walk through all the "buckets" looking
for the value, using object.Equals to check each bucket's value.
 
Back
Top