Dictionaries, Sets, and BST

Dictionary/Map ADT

public interface Dictionary<K, V>{

  /**
   * Insert an entry into the dictionary. Return the previous value, or null if
   * there was no previous value associated with this key
   */
  V put(K key, V value);

  /**
   * Return the value associated with the provided key, or null if this key is not
   * in the dictionary.
   */
  V get(K key);

  /**
   * Remove the indicated entry from the dictionary. Returns true if something was
   * actually removed.
   */
  boolean remove(K key);

  /**
   * Return true if the provided key is in the dictionary.
   */
  boolean contains(K key);

  /**
   * Return the number of entries in the dictionary.
   */
  int size();
}

See also: java.util.Map

Set ADT

public interface Set<E> {

  /**
   * Add an item to the set if it is not already a member. Returns true if the set
   * was modified, false if the item was already in the set.
   */
  boolean add(E item);

  /**
   * Remove the indicated item from the set if it is present. Returns true if the
   * item was in the set.
   */
  boolean remove(E item);

  /**
   * Return true if the indicated item is in the set.
   */
  boolean contains(E item);

  /**
   * Return the number of elements in this set.
   */
  int size();

}

See also: java.util.Set