Code example for SortedSet

Methods: add

0
	public Completer() { 
		lexicon = new TreeSet<String>();
	} 
	 
	public void addWord(String word) {
		lexicon.add(word);
	} 
	 
	public SortedSet<String> getCompletions(String prefix) {
		return lexicon.subSet(prefix, prefix + Character.MAX_VALUE);
	} 
	 
	/** 
	 * Find the greatest common prefix of a sorted set. 
	 * @param compl 
	 * @return 
	 */ 
	public static String greatestCommonPrefix(SortedSet<String> compl) {
		StringBuilder buf = new StringBuilder(compl.last().length());
		char[] s1 = compl.first().toCharArray();
		char[] s2 = compl.last().toCharArray();