T
- The type of objects stored in the trie pathsU
- The type of objects stored in the trie end pointspublic class SimpleTrie<T,U>
extends java.lang.Object
Constructor and Description |
---|
SimpleTrie()
Creates a new trie
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(java.util.List<T> path)
Adds a child along the given path, and marks the last element node as a valid end point
|
void |
addChild(T... elements)
Adds a child along the given path, and marks the last element node as a valid end point
|
boolean |
equals(java.lang.Object otherObject) |
SimpleTrie<T,U> |
getChild(java.util.List<T> path)
Gets the child at the end of the given path (or null if there is no such element)
|
SimpleTrie<T,U> |
getChild(T... elements)
Gets the child at the end of the given path (or null if there is no such element)
|
java.util.Map<T,SimpleTrie<T,U>> |
getChildren()
Returns the child map for this level of the trie.
|
U |
getEndPointValue()
Returns the end-point value for this node, regardless of if it's a valid end point.
|
boolean |
hasChild(T... elements)
Checks if there is a child node by following the given path
|
int |
hashCode() |
boolean |
hasValidEndPoint(java.util.List<T> path)
Checks if there is a valid end node at the end of the given path
|
boolean |
hasValidEndPoint(T... elements)
Checks if there is a valid end node at the end of the given path
|
boolean |
isValidEndPoint()
Returns true if this node is a valid end point.
|
void |
setEndPointValue(U endPointValue)
Sets the end point value for this node
|
void |
setValidEndPoint(boolean validEndPoint)
Sets whether or not this is a valid end point
|
java.lang.String |
toString() |
@SafeVarargs public final void addChild(@NotNull T... elements)
elements
- The elements along the pathpublic final void addChild(@NotNull java.util.List<T> path)
path
- The elements along the path@SafeVarargs public final boolean hasChild(@NotNull T... elements)
elements
- The elements in the path (if empty is given return true as this is the current element which obviously exists)@SafeVarargs public final boolean hasValidEndPoint(@NotNull T... elements)
elements
- The elements in the path (if empty is given return true as this is the current element which obviously exists)public boolean hasValidEndPoint(@NotNull java.util.List<T> path)
path
- The elements in the path (if empty is given return true as this is the current element which obviously exists)public void setValidEndPoint(boolean validEndPoint)
validEndPoint
- True if this is a valid end point, false otherwisepublic boolean isValidEndPoint()
public void setEndPointValue(@Nullable U endPointValue)
endPointValue
- The end point value for this node@Nullable public U getEndPointValue()
@SafeVarargs @Nullable public final SimpleTrie<T,U> getChild(@NotNull T... elements)
elements
- The path to follow@Nullable public SimpleTrie<T,U> getChild(@NotNull java.util.List<T> path)
path
- The path to followpublic java.util.Map<T,SimpleTrie<T,U>> getChildren()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object otherObject)
equals
in class java.lang.Object