/**
  * Unit tests the {@code SequentialSearchST} data type.
  *
  * @param args the command-line arguments
  */
 public static void main(String[] args) {
     SequentialSearchST<String, Integer> st = new SequentialSearchST<String, Integer>();
     for (int i = 0; !StdIn.isEmpty(); i++) {
         String key = StdIn.readString();
         st.put(key, i);
     }
     for (String s : st.keys())
         StdOut.println(s + " " + st.get(s));
 }
Exemple #2
0
 /**
  * Initializes an empty symbol table with {@code m} chains.
  * @param m the initial number of chains
  */
 public SeparateChainingHashST(int m) {
     this.m = m;
     st = (SequentialSearchST<Key, Value>[]) new SequentialSearchST[m];
     for (int i = 0; i < m; i++)
         st[i] = new SequentialSearchST<Key, Value>();
 }