Package cs2110

Interface StringDict<V>

All Superinterfaces:
Iterable<V>
All Known Implementing Classes:
JavaStringDict, ProbingStringDict

public interface StringDict<V> extends Iterable<V>
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 Type
    Method
    Description
    boolean
    Return whether a value is associated with key `key`.
    get(String key)
    Return the value associated with key `key`.
    void
    put(String key, V value)
    Associate value `value` with key `key`.
    int
    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

      V get(String key)
      Return the value associated with key `key`. Throws `NoSuchElementException` if no value is associated with that key. Requires `key` is not null.
    • put

      void put(String key, V value)
      Associate value `value` with key `key`. Requires `key` and `value` are not null.
    • containsKey

      boolean containsKey(String key)
      Return whether a value is associated with key `key`.