public class Trie extends AbstractSet<CharSequence>
| Modifier and Type | Field and Description |
|---|---|
protected TreeMap<Character,Trie> |
children
Holds the children
|
protected boolean |
isWord
true if this is a word
|
protected Trie |
parent
maps to parent
|
protected int |
size
number of elements
|
| Modifier | Constructor and Description |
|---|---|
|
Trie()
Constructs a Trie
|
|
Trie(Collection<String> keySet)
Constructs a trie
|
protected |
Trie(Trie p)
Constructs a Trie
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(CharSequence s) |
protected boolean |
add(CharSequence s,
int start)
Adds a sequence starting from start position
|
void |
clear() |
int |
containedLength(CharSequence s,
int startPos)
Returns the length of the longest contained subsequence, starting from
start position
|
boolean |
contains(Object s) |
protected boolean |
containsCS(CharSequence cs,
int start)
TRUE if the trie contains the sequence from start position on
|
boolean |
isEmpty() |
PeekIterator<CharSequence> |
iterator() |
static void |
main(String[] args)
Test method
|
int |
size() |
Iterator<String> |
stringIterator() |
Iterable<String> |
strings() |
String |
toString() |
PeekIterator<CharSequence> |
wordsIn(CharSequence text)
Returns all words found
|
equals, hashCode, removeAlladdAll, containsAll, remove, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, remove, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streamprotected boolean isWord
protected int size
protected Trie parent
public Trie()
protected Trie(Trie p)
public Trie(Collection<String> keySet)
public boolean add(CharSequence s)
add in interface Collection<CharSequence>add in interface Set<CharSequence>add in class AbstractCollection<CharSequence>public void clear()
clear in interface Collection<CharSequence>clear in interface Set<CharSequence>clear in class AbstractCollection<CharSequence>public boolean isEmpty()
isEmpty in interface Collection<CharSequence>isEmpty in interface Set<CharSequence>isEmpty in class AbstractCollection<CharSequence>protected boolean add(CharSequence s, int start)
public boolean contains(Object s)
contains in interface Collection<CharSequence>contains in interface Set<CharSequence>contains in class AbstractCollection<CharSequence>protected boolean containsCS(CharSequence cs, int start)
public PeekIterator<CharSequence> iterator()
iterator in interface Iterable<CharSequence>iterator in interface Collection<CharSequence>iterator in interface Set<CharSequence>iterator in class AbstractCollection<CharSequence>public String toString()
toString in class AbstractCollection<CharSequence>public int size()
size in interface Collection<CharSequence>size in interface Set<CharSequence>size in class AbstractCollection<CharSequence>public int containedLength(CharSequence s, int startPos)
public PeekIterator<CharSequence> wordsIn(CharSequence text)
public static void main(String[] args)
Copyright © 2018. All rights reserved.