|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.core.Trie
public class Trie
A class representing a Trie data structure for strings. See also Trie on WikiPedia.
| Nested Class Summary | |
|---|---|
static class |
Trie.TrieIterator
Represents an iterator over a trie |
static class |
Trie.TrieNode
Represents a node in the trie. |
| Constructor Summary | |
|---|---|
Trie()
initializes the data structure |
|
| Method Summary | ||
|---|---|---|
boolean |
add(String o)
Ensures that this collection contains the specified element. |
|
boolean |
addAll(Collection<? extends String> c)
Adds all of the elements in the specified collection to this collection |
|
void |
clear()
Removes all of the elements from this collection |
|
Object |
clone()
returns a deep copy of itself |
|
boolean |
contains(Object o)
Returns true if this collection contains the specified element. |
|
boolean |
containsAll(Collection<?> c)
Returns true if this collection contains all of the elements in the specified collection. |
|
boolean |
containsPrefix(String prefix)
checks whether the given prefix is stored in the trie |
|
boolean |
equals(Object o)
Compares the specified object with this collection for equality. |
|
String |
getCommonPrefix()
returns the common prefix for all the nodes |
|
String |
getRevision()
Returns the revision string. |
|
Trie.TrieNode |
getRoot()
returns the root node of the trie |
|
Vector<String> |
getWithPrefix(String prefix)
returns all stored strings that match the given prefix |
|
int |
hashCode()
Returns the hash code value for this collection. |
|
boolean |
isEmpty()
Returns true if this collection contains no elements. |
|
Iterator<String> |
iterator()
Returns an iterator over the elements in this collection. |
|
static void |
main(String[] args)
Only for testing (prints the built Trie). |
|
boolean |
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present. |
|
boolean |
removeAll(Collection<?> c)
Removes all this collection's elements that are also contained in the specified collection |
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection |
|
int |
size()
Returns the number of elements in this collection. |
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. |
|
String |
toString()
returns the trie in string representation |
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Trie()
| Method Detail |
|---|
public boolean add(String o)
add in interface Collection<String>o - the string to add
public boolean addAll(Collection<? extends String> c)
addAll in interface Collection<String>c - the collection to addpublic void clear()
clear in interface Collection<String>public Object clone()
clone in class Objectpublic boolean contains(Object o)
contains in interface Collection<String>o - the object to check for in trie
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<String>c - the collection to look for in the trie
public boolean containsPrefix(String prefix)
prefix - the prefix to check
public boolean equals(Object o)
equals in interface Collection<String>equals in class Objecto - the object to check for equalitypublic String getCommonPrefix()
public Trie.TrieNode getRoot()
public Vector<String> getWithPrefix(String prefix)
prefix - the prefix that all strings must have
public int hashCode()
hashCode in interface Collection<String>hashCode in class Objectpublic boolean isEmpty()
isEmpty in interface Collection<String>public Iterator<String> iterator()
iterator in interface Iterable<String>iterator in interface Collection<String>public boolean remove(Object o)
remove in interface Collection<String>o - the object to remove
public boolean removeAll(Collection<?> c)
removeAll in interface Collection<String>c - the collection to remove
public boolean retainAll(Collection<?> c)
retainAll in interface Collection<String>c - the collection to use as reference
public int size()
size in interface Collection<String>public Object[] toArray()
toArray in interface Collection<String>public <T> T[] toArray(T[] a)
toArray in interface Collection<String>a - the array into which the elements of this collection
are to be stored
public String toString()
toString in class Objectpublic String getRevision()
getRevision in interface RevisionHandlerpublic static void main(String[] args)
args - commandline arguments
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||