Interface Trie<V>
-
public interface Trie<V>A prefix tree that maps from the longest matching prefix to a valueV.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTrie.Builder<V>
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <V> Trie.Builder<V>builder()Start building a trie.default booleancontains(CharSequence str)Returnstrueif this trie contains the prefixstr.VgetOrDefault(CharSequence str, V defaultValue)Returns the value associated with the longest matched prefix, or thedefaultValueif there wasn't a match.default VgetOrNull(CharSequence str)Returns the value associated with the longest matched prefix, or null if there wasn't a match.
-
-
-
Method Detail
-
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)entrytrie.getOrNull("abcd")will return10.
-
getOrDefault
V getOrDefault(CharSequence str, V defaultValue)
Returns the value associated with the longest matched prefix, or thedefaultValueif there wasn't a match. For example: for a trie containing an("abc", 10)entrytrie.getOrDefault("abcd", -1)will return10.
-
contains
default boolean contains(CharSequence str)
Returnstrueif this trie contains the prefixstr.
-
-