The Dictionary class differs from the Hashtable class in
more ways than one. In addition to being strongly-typed, the
Dictionary also employs a different collision
resolution strategy than the Hashtable class, using a
technique referred to as
chaining. Recall that with
probing, in the event of a collision another slot in the
list of buckets is tried. (With rehashing, the hash is
recomputed, and that new slot is tried.) With chaining,
however, a secondary data structure is utilized to hold any
collisions. Specifically, each slot in the
Dictionary
has an array of elements that map to that bucket. In the
event of a collision, the colliding element is prepended to
the bucket's list.
To better understand how chaining
works, it helps to visualize the Dictionary as a
hashtable whose buckets each contain a linked list of items
that hash to that particular bucket. Figure 11 illustrates
how series of items that hash to the same bucket will form a
chain on that bucket.