A dictionary key is a value that identifies an associated entry. In a dictionary, each possible key appears at most once, and the key retrieves its value directly. section 4.3
Keys support several related data-structure roles:
- Generalize array indices: an ordinary array uses positions from zero through size minus one as its keys, while a dictionary can draw keys from virtually any domain. section 4.3
- Define ordering in a binary search tree: smaller keys belong in the left subtree and larger keys in the right subtree. section 3.3
- Remain distinct from priority: a treap orders entries by key while using a separate priority to maintain heap behavior. section 3.2 section 3.3
- Permit lookup by transformation into indices; with bounded key length, checking the resulting positions takes constant time. section 4.9.4
Email contacts
Store contacts as key-value pairs in an in-memory dictionary, using a contact identifier as the key. When a recipient is entered, check the dictionary before asking whether to save the contact; insert and remove keep the local collection synchronized. section 4.3
The associative-array API makes the key’s operational role explicit through insert, remove, and contains. section 4.3









