net.jakubholy.jedit.autocomplete
Class WordListTreeSet

java.lang.Object
  extended by net.jakubholy.jedit.autocomplete.WordListTreeSet
All Implemented Interfaces:
WordList

public class WordListTreeSet
extends java.lang.Object
implements WordList

A WordList implementation based on java.util.TreeSet (which implements OrderedSet). It is synchronized.


Field Summary
protected  java.util.TreeSet<net.jakubholy.jedit.autocomplete.Completion> treeSet
           
 
Constructor Summary
WordListTreeSet()
           
 
Method Summary
 boolean add(net.jakubholy.jedit.autocomplete.Completion completion)
          Insert the completion into the list.
 void addAll(net.jakubholy.jedit.autocomplete.Completion[] completions)
           
 void addObserver(java.util.Observer o)
          Add an observer interested in receiving WordListEvents whenever the contents of this word list changes (completion added/removed, cleared).
 void clear()
          Removes all of the elements from this wordList.
 boolean containes(net.jakubholy.jedit.autocomplete.Completion completion)
          Return true if is in the list.
 void deleteObserver(java.util.Observer o)
          Stop observing this word list.
 net.jakubholy.jedit.autocomplete.Completion[] getAllWords()
          Returns all words in the list in a sorted array.
 net.jakubholy.jedit.autocomplete.Completion[] getCompletions(java.lang.String prefix)
          Return an array of all words in the list starting with the given prefix and longer than that prefix.
 boolean remove(net.jakubholy.jedit.autocomplete.Completion completion)
          Removes the specified element from this wordList if it is present.
 int size()
          Returns the number of elements in this wordlist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

treeSet

protected java.util.TreeSet<net.jakubholy.jedit.autocomplete.Completion> treeSet
Constructor Detail

WordListTreeSet

public WordListTreeSet()
Method Detail

getCompletions

public net.jakubholy.jedit.autocomplete.Completion[] getCompletions(java.lang.String prefix)
Description copied from interface: WordList
Return an array of all words in the list starting with the given prefix and longer than that prefix.

Specified by:
getCompletions in interface WordList
Parameters:
prefix - The prefix whose completions we search; at least 1 letter.
Returns:
An array of possible completions of an empty array. Entries in the array are sorted.

getAllWords

public net.jakubholy.jedit.autocomplete.Completion[] getAllWords()
Description copied from interface: WordList
Returns all words in the list in a sorted array.

Specified by:
getAllWords in interface WordList

add

public boolean add(net.jakubholy.jedit.autocomplete.Completion completion)
Description copied from interface: WordList
Insert the completion into the list.

Specified by:
add in interface WordList
Returns:
False if the completion has already been in the list.

remove

public boolean remove(net.jakubholy.jedit.autocomplete.Completion completion)
Description copied from interface: WordList
Removes the specified element from this wordList if it is present.

Specified by:
remove in interface WordList

clear

public void clear()
Description copied from interface: WordList
Removes all of the elements from this wordList.

Specified by:
clear in interface WordList

addAll

public void addAll(net.jakubholy.jedit.autocomplete.Completion[] completions)
Specified by:
addAll in interface WordList

size

public int size()
Description copied from interface: WordList
Returns the number of elements in this wordlist.

Specified by:
size in interface WordList

containes

public boolean containes(net.jakubholy.jedit.autocomplete.Completion completion)
Description copied from interface: WordList
Return true if is in the list.

Specified by:
containes in interface WordList

addObserver

public void addObserver(java.util.Observer o)
Description copied from interface: WordList
Add an observer interested in receiving WordListEvents whenever the contents of this word list changes (completion added/removed, cleared).

Specified by:
addObserver in interface WordList

deleteObserver

public void deleteObserver(java.util.Observer o)
Description copied from interface: WordList
Stop observing this word list.

Specified by:
deleteObserver in interface WordList