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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> Trie.Builder<V>builder()Start building a trie.default booleancontains(CharSequence str) Returnstrueif this trie contains the prefixstr.getOrDefault(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 Details
-
builder
Start building a trie. -
getOrNull
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
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
Returnstrueif this trie contains the prefixstr.
-