public final class Trie
extends java.lang.Object
Constructor and Description |
---|
Trie()
create a public root Trie.
|
Modifier and Type | Method and Description |
---|---|
int |
count()
count the number of words in the current tree.
|
char |
getChar()
Get own character.
|
int |
getId()
return current id.
|
java.lang.Object |
getObject()
Get the assigend object.
|
Trie |
getParent()
get the parent Trie.
|
java.lang.String |
getString()
Reconstruct the word.
|
Trie |
insert(char[] b,
int newId)
Insert a word into current Trie.
|
Trie |
insert(java.lang.String s,
int newId)
Insert a word into current Trie.
|
int |
length()
Return the length of the path for the current Trie.
|
int |
remove(char[] b)
Remove a word from current Trie.
|
int |
remove(java.lang.String s)
Remove a word from current Trie.
|
Trie |
search(char[] b)
Search a word in current Trie.
|
Trie |
search(java.lang.String s)
Search a word in current Trie.
|
Trie |
searchLast(java.lang.String path,
int id)
Search the last node in the path where the id fits an id in a node.
|
void |
setObject(java.lang.Object object)
Assign an object.
|
Trie |
step(int c)
Step one digit down in current Trie.
|
char[] |
toCharArray()
reconstruct the word.
|
public Trie insert(java.lang.String s, int newId)
s
- the string which is added.newId
- the IDpublic Trie insert(char[] b, int newId)
b
- the chars of the string which is added.newId
- the IDpublic Trie search(java.lang.String s)
s
- the string which is searched.public Trie search(char[] b)
b
- the characters of the string which is searched.public Trie searchLast(java.lang.String path, int id)
path
- the pathid
- the id to searchpublic int remove(java.lang.String s)
s
- the string which is removed.public int remove(char[] b)
b
- the characters of the string which is removed.public int count()
public Trie step(int c)
c
- character to steppublic int getId()
public char[] toCharArray()
public java.lang.String getString()
public char getChar()
public Trie getParent()
public void setObject(java.lang.Object object)
object
- the assigned object.getObject()
public java.lang.Object getObject()
setObject(java.lang.Object)
public int length()