Source of SortedArrayDictionary.java


  1: import java.util.Arrays;
  2: import java.util.Iterator;
  3: import java.util.NoSuchElementException;

  5: /**
  6:    A class that implements the ADT dictionary by using a resizable array.
  7:    The dictionary is sorted and has distinct search keys. Search keys and
  8:    associated values are not null.
  9:  
 10:    @author Frank M. Carrano
 11:    @author Timothy M. Henry
 12:    @version 5.0
 13: */
 14: public class SortedArrayDictionary<K extends Comparable<? super K>, V>
 15:              implements DictionaryInterface<K, V>
 16: {
 17:         private Entry<K, V>[] dictionary; // Array of entries sorted by search key
 18:         private int numberOfEntries; 
 19:    private boolean integrityOK = false;
 20:         private final static int DEFAULT_CAPACITY = 25;
 21:         private static final int MAX_CAPACITY = 10000;

 23: /* < Constructors analogous to those in Listing 21-1.
 24:      . . .
 25:      Implementations of methods in DictionaryInterface.
 26:       . . .
 27:      The private class Entry, as shown in Listing 21-1.
 28:      . . .
 29:  */
 30: } // end SortedArrayDictionary