Card 09/ 09

RecapDifficulty: Advanced1 min

Recap: Maps and HashMap Internals

Hashing to a bucket, collisions, tree buckets, resizing, and null keys, with where each was.

Maps come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
A lookup hashes, picks one bucket, and searches only that bucketHow a HashMap Finds a Value: Hashing and Buckets
A collision keeps both entries; only an equal key replaces a valueHash Collisions: Two Keys in the Same Bucket
An overloaded bucket becomes a tree at eight entriesHashMap Example: A Crowded Bucket Turns Into a Tree
Sixteen buckets, a load factor of 0.75, and a rebuild that moves everythingHashMap Resizing: The Load Factor and the Rebuild
A TreeMap refuses null keys because it has to compare themNull Keys: Allowed in HashMap, Refused by TreeMap

A map's speed is borrowed from the key's hashCode, and nearly every map problem is that loan going bad.