OUTLINE FOR COSC 2006 TEST ========================== Question 1: Bag interface and DynamicBag class Question 2: Array interface and DynamicArray class Question 3: Set interface with TreeSet and HashSet classes Question 4: Map interface with HashMap class You should know the Iterator interface (hasNext(), next()) and the for each loop for traversals. Summaries of the Bag, Array, Set and Map interfaces will be provided. Questions will ask you to write a method or some statements to do something. Interface summaries =================== The Bag interface ----------------- public interface Bag { int size(); boolean isEmpty(); boolean add(E element); boolean remove(E element); boolean contains(E element); } The Array interface ------------------- public interface Array { int size(); boolean isEmpty(); boolean add(E element); E get(int index); void set(int index, E element); void add(int k, E element); E remove(int k); } The Set interface ----------------- public interface Set { int size(); boolean isEmpty(); boolean add(E element); boolean contains(Object element) Iterator iterator(); boolean remove(Object obj); } The Map interface ----------------- public interface Map { int size(); boolean isEmpty(); boolean containsKey(Object key); V get(Object key); V put(K key, V value); // put new key value pair into map Set keySet(); // return keys as a set // ... Other methods not needed } Useful result System.arraycopy(Object source, int sourceIndex, Object dest, int destIndex, int n); Here source is a reference to the source array, sourceIndex is the starting index in the source array, dest is a reference to the destination array, destIndex is the starting index in the destination array, and n is the number of array elements to copy.