Interface Trie<V>


public interface Trie<V>
A prefix tree that maps from the longest matching prefix to a value V.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <V> Trie.Builder<V>
    Start building a trie.
    default boolean
    Returns true if this trie contains the prefix str.
    getOrDefault(CharSequence str, V defaultValue)
    Returns the value associated with the longest matched prefix, or the defaultValue if there wasn't a match.
    default V
    Returns the value associated with the longest matched prefix, or null if there wasn't a match.
  • Method Details

    • builder

      static <V> Trie.Builder<V> builder()
      Start building a trie.
    • getOrNull

      @Nullable default V getOrNull(CharSequence str)
      Returns the value associated with the longest matched prefix, or null if there wasn't a match. For example: for a trie containing an ("abc", 10) entry trie.getOrNull("abcd") will return 10.
    • getOrDefault

      V getOrDefault(CharSequence str, V defaultValue)
      Returns the value associated with the longest matched prefix, or the defaultValue if there wasn't a match. For example: for a trie containing an ("abc", 10) entry trie.getOrDefault("abcd", -1) will return 10.
    • contains

      default boolean contains(CharSequence str)
      Returns true if this trie contains the prefix str.