Package cs2110
Interface StringDict<V>
- All Superinterfaces:
Iterable<V>
- All Known Implementing Classes:
JavaStringDict
,ProbingStringDict
A dictionary mapping String keys to values of type `V`. This is a simpler, specialized
alternative to Java's `Map` interface. Supports iterating over _values_ in an unspecified
order.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) Return whether a value is associated with key `key`.Return the value associated with key `key`.void
Associate value `value` with key `key`.int
size()
Return the number of keys currently mapped to values in this dictionary.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Return the number of keys currently mapped to values in this dictionary. -
get
Return the value associated with key `key`. Throws `NoSuchElementException` if no value is associated with that key. Requires `key` is not null. -
put
Associate value `value` with key `key`. Requires `key` and `value` are not null. -
containsKey
Return whether a value is associated with key `key`.
-