When NOT to Use

Avoid forcing this pattern

Avoid forcing this pattern when:

  • Need ordered iteration: Hash maps don't maintain insertion order in all languages. Use TreeMap or sorted structures if order matters.
  • Memory is severely constrained: Hash maps use O(n)O(n) extra space.

In-place algorithms might be required.

  • Keys aren't hashable: Custom objects need proper hash functions. Sometimes sorting or other approaches are simpler.