Map
To ground many of the ideas in the classification module,
we introduce one of the most comprehensive data structures used in computer
science, as well as numerous disciplines.
A Map is "an object that maps keys to values. A map cannot
contain duplicate keys; each key can map to at most one value."
Numerous examples of maps exist in the real world:
- A
telephone book maps names to phone numbers.
- An atlas maps street names (i.e., "Maple Street") to
locations on a geographic map ("E7")
- A domain name server maps a computer name to an
IP address.
- The periodic table maps an element's abbreviation
(i.e., "Na") to a data sheet in which
lots of information about that element may be found (i.e., atomic weight).
Given a map, there are numerous operations that one would
like to perform:
- Cardinality
- int
size()
- boolean isEmpty()
- Find
- boolean containsKey
(Object key)
- boolean containsValue (Object
value)
- Object get
(Object key)
- Insert
- Object
put (Object key,
Object value)
- Remove
- Object remove
(Object key)
- void clear ()