Card 09/ 09
All 9 cards
RecapDifficulty: Advanced1 min
One Hash, One Bucket, One Comparison
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
| A lookup hashes, picks one bucket, and searches only that bucket | How a Map Finds One Value |
| A collision keeps both entries; only an equal key replaces a value | What Happens When Two Keys Land in the Same Bucket |
| An overloaded bucket becomes a tree at eight entries | A Bucket That Grew Long Enough to Become a Tree |
| Sixteen buckets, a load factor of 0.75, and a rebuild that moves everything | Watching a Map Rebuild Itself |
A TreeMap refuses null keys because it has to compare them | Why a null Key Is Fine in One Map |
A map's speed is borrowed from the key's hashCode, and everything that goes wrong with a map is that loan going bad — keys that all hash alike, keys that hash differently on the way out, or too many entries for the buckets there are.