
476 A Practical Guide to Data Structures and Algorithms Using Java
public boolean contains(E target) {
return (!find(target).isFrontier());
}
Correctness Highlights: By the correctness of find, the desired element is in the collection
exactly when the value returned is not a frontier node.
The method get takes r, the desired rank. It returns the r
th
element in the sorted order, where
r = 0 is the minimum. It throws an IllegalArgumentException when r < 0 or r ≥ n.
public E get(int r) {
if (r < 0 || r ≥ getSize())
throw new IllegalArgumentException();
Locator<E> loc = iterator();
for (int j=0; j < r+1; j++, loc.advance());
return loc.get();
}
Correctness Highlights: ...