Code example for TreeMap

Methods: clear

0
public class PrefixTree<T> { 
 
    private TreeMap<String, T> holder = new TreeMap<String, T>();
 
    public void clear() { 
        holder.clear();
    } 
 
    public void add(String key, T entry) {
        holder.put(key, entry);
    } 
 
    public T findBy(String prefix) {
        if (prefix == null)
            return null; 
 
        String nextKey = holder.ceilingKey(prefix);
        if (nextKey == null)
            return null; 
 
        SortedMap<String, T> tail = holder.tailMap(nextKey);