Algorithms and OOD (CSC 207 2014S) : EBoards

CSC207.01 2014S, Class 37: Designing a Dictionary API



Upcoming work


Extra Credit

Academic Honesty

Notes on Exam 2

Questions on the homework

How will the user interact with the calculator?

Similarly to dc. Read the inputs from stdin, print the outputs (from p and s) to stdout.

The bad version of queues has an iterator (which may be well designed). What do we have to do?

All collections have iterators, mostly so you can skim through the collection without mutating it.

Review: Designing ADTs and Data Structures


Data Structure

A Dictionary ADT

Simple Dictionary, indexed by strings

The interface

public interface SimpleDictionary<T>
   * Change the entry for a particular index.
  void set(String index, T value);

   * Remove a value based on its index.
  void remove(String index);

   * Remove everything.
  void clear();

   * Remove all the entries with a given value.
  void removeAll(T val);

   * Get all of the indices in the dictionary.
  Iterator<String> indices();

   * Get all of the values in the dictionary.
  Iterator<T> iterator();

} // interface SimpleDictionary<T>

Generalizing: Replace "String" with a type variable

public interface Dictionary<I,T>
} // interface Dictionary<I,T>

Other notes about dictionaries

Lots of related names:

Simple implementations of dictionaries


Copyright (c) 2013-14 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.