Java Arena

Module 45

Building your own list and hash map

How ArrayList and HashMap work inside, by building your own. A list on top of an array that grows, with add, get, indexOf, contains and remove; a generic version made with (T[]) new Object[...]; a hash map with an array of buckets, hash codes, collisions, updates, removing and growing; and why its lookups stay fast. MOOC section 12.2.

Steps

  1. An array's size is fixed
  2. A list of your own
  3. get, indexOf and contains
  4. Removing, and moving the rest along
  5. Any type: a generic list
  6. A hash map of your own
  7. Collisions, updates, removing and growing
  8. Why lookups stay fast