Class CharTree<T>

java.lang.Object
redempt.crunch.data.CharTree<T>
Type Parameters:
T - The type stored in this CharTree

public class CharTree<T> extends Object
A simple implementation of a prefix tree for better parsing Only supports ASCII characters
  • Constructor Details

    • CharTree

      public CharTree()
  • Method Details

    • set

      public void set(String str, T value)
      Sets a String in this CharTree
      Parameters:
      str - The String to use as the key
      value - The value to store
    • get

      public T get(String str)
      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

      public Pair<T,Integer> getFrom(String str, int index)
      Gets a token forward from the given index in a string
      Parameters:
      str - The string to search in
      index - The starting index to search from
      Returns:
      A pair with the token or null if none was found, and the length parsed
    • getWith

      public T getWith(ExpressionParser parser)