public static class Trie.TrieNode extends DefaultMutableTreeNode implements RevisionHandler
Modifier and Type | Field and Description |
---|---|
static Character |
STOP
the stop character
|
EMPTY_ENUMERATION
Constructor and Description |
---|
TrieNode(char c)
initializes the node
|
TrieNode(Character c)
initializes the node
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(String suffix)
adds the given string to its children (creates children if necessary)
|
Object |
clone()
creates a deep copy of itself
|
boolean |
contains(String suffix)
checks whether a suffix can be found in its children
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
Trie.TrieNode |
find(String suffix)
returns the node with the given suffix
|
Character |
getChar()
returns the stored character
|
String |
getCommonPrefix()
returns the common prefix for all the nodes starting with this node.
|
String |
getCommonPrefix(String startPrefix)
returns the common prefix for all the nodes starting with the node for
the specified prefix.
|
String |
getRevision()
Returns the revision string.
|
String |
getString()
returns the full string up to the root
|
boolean |
remove(String suffix)
Removes a suffix from the trie.
|
void |
setChar(Character value)
sets the character this node represents
|
int |
size()
returns the number of stored strings, i.e., leaves
|
String |
toString()
returns the node in a string representation
|
add, breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
public static final Character STOP
public TrieNode(char c)
c
- the value of this nodepublic TrieNode(Character c)
c
- the value of this nodepublic Character getChar()
public void setChar(Character value)
value
- the character to storepublic boolean add(String suffix)
suffix
- the suffix to add to its childrenpublic boolean remove(String suffix)
suffix
- the suffix to removepublic boolean contains(String suffix)
suffix
- the suffix to look forpublic Object clone()
clone
in class DefaultMutableTreeNode
public boolean equals(Object obj)
public Trie.TrieNode find(String suffix)
suffix
- the suffix to look forpublic String getCommonPrefix()
public String getCommonPrefix(String startPrefix)
startPrefix
- the prefix of the node to start the search frompublic int size()
public String getString()
public String toString()
toString
in class DefaultMutableTreeNode
public String getRevision()
getRevision
in interface RevisionHandler
Copyright © 2019 University of Waikato, Hamilton, NZ. All rights reserved.