The ordered symbol table has all the same methods as the symbol table with unordered keys (in gray).
The additions to the unordered symbol table are
- The generic Key type is now declared to be Comparable<Key>
- The obvious methods managing the minimum and maximum keys (in blue)
- Methods floor and ceiling, useful for finding "nearest" key (in red)
- Methods rank and select, useful for finding the position of key in the ordering or finding key at a given position.(in green)
public class ST<Key extends Comparable<Key>, Value> {
public void put( Key key, Value val) {...}
public Value get( Key key) {...}
public void delete( Key key) {...}
public boolean contains(Key key) {...}
public int size() {...}
public boolean isEmpty() {...}
public Iterable<Key> keys() {...}
public Key min() {...}
public Key max() {...}
public void deleteMin() {...}
public void deleteMax() {...}
public Key floor( Key key) {...}
public Key ceiling( Key key) {...}
public int rank( Key key) {...}
public Key select( int k) {...}
}