Package redempt.crunch.data
Class CharTree<T>
java.lang.Object
redempt.crunch.data.CharTree<T>
- Type Parameters:
T
- The type stored in this CharTree
A simple implementation of a prefix tree for better parsing
Only supports ASCII characters
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsFirstChar
(char c) Check if the character exists at the root level in this treeGets a value by its keyGets a token forward from the given index in a stringgetWith
(ExpressionParser parser) void
Sets a String in this CharTree
-
Constructor Details
-
CharTree
public CharTree()
-
-
Method Details
-
set
Sets a String in this CharTree- Parameters:
str
- The String to use as the keyvalue
- The value to store
-
get
Gets a value by its key- Parameters:
str
- The key- Returns:
- The value mapped to the key, or null if it is not present
-
containsFirstChar
public boolean containsFirstChar(char c) Check if the character exists at the root level in this tree- Parameters:
c
- The character to check- Returns:
- Whether the character exists at the root level
-
getFrom
Gets a token forward from the given index in a string- Parameters:
str
- The string to search inindex
- The starting index to search from- Returns:
- A pair with the token or null if none was found, and the length parsed
-
getWith
-