public final class TrieNode extends Object
Constructor and Description |
---|
TrieNode() |
Modifier and Type | Method and Description |
---|---|
TrieNode |
deleteIf(String path,
java.util.function.Function<TrieNode,Boolean> predicate)
Deletes the path from the Trie if the given predicate is true.
|
Iterator<TrieNode> |
getCommonRoots() |
boolean |
hasTerminal(String path,
boolean includeChildren)
Checks whether the path has terminal nodes as parents or children.
|
TrieNode |
insert(String path)
Inserts a path into the trie.
|
List<TrieNode> |
search(String path)
Traverses the trie along the path components until the traversal cannot proceed any more.
|
public TrieNode insert(String path)
path
- a path with components separated by "/"public List<TrieNode> search(String path)
path
- the target pathpublic boolean hasTerminal(String path, boolean includeChildren)
path
- the target pathincludeChildren
- whether the check should succeed if the path has children terminal nodespublic TrieNode deleteIf(String path, java.util.function.Function<TrieNode,Boolean> predicate)
path
- the target pathpredicate
- a predicate to decide whether the node should be deleted or notCopyright © 2023. All Rights Reserved.