All pastes #262146 Raw Edit

Stuff

public cpp v1 · immutable
#262146 ·published 2006-11-30 05:30 UTC
rendered paste body
        public void insert(String key) {            if (!contains(key)) {                int i;                  int loc = h(key);                     for (i = 0; i < N && table[loc].isOccupied(); i++) {                    loc = (loc+1)%N;                }                    if (i < N) {                    table[loc] = new Entry('o',key);                }            }        }            public boolean contains(String key) {            int loc = h(key);             int i;                  for (i = 0; i < N && !table[loc].isEmpty(); i++) {                if (table[loc].isOccupied()) {                    nComparisons++;                    if (table[loc].equals(key)) {                        return true;                    }                }                loc = (loc+1)%N;            }                return false;        }