Package owl.collections
Class TrieMap<K,V>
- java.lang.Object
-
- owl.collections.TrieMap<K,V>
-
- Type Parameters:
K
- List of K ist a key in this map.V
- Values stored.
public class TrieMap<K,V> extends Object
A TrieMap is a Map with sequences as keys that are organized in a Trie for value retrieval.
-
-
Constructor Summary
Constructors Constructor Description TrieMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
TrieMap<K,V>create()
Returns a fresh empty trie.Optional<V>
get(List<K> ks, boolean any)
Retrieve value at given key.Optional<V>
getRootValue()
boolean
has(List<K> ks, boolean inSubtree)
Check whether the value at the precise given key (for inSubtree=false) or its subtree (for inSubtree=true) exists.boolean
isEmpty()
void
put(List<K> ks, V val)
Put value at provided key position.int
size()
Returns size (O(n) operation, traverses tree).Optional<TrieMap<K,V>>
traverse(List<K> ks, boolean create)
-
-
-
Method Detail
-
create
public static <K,V> TrieMap<K,V> create()
Returns a fresh empty trie.
-
isEmpty
public boolean isEmpty()
-
has
public boolean has(List<K> ks, boolean inSubtree)
Check whether the value at the precise given key (for inSubtree=false) or its subtree (for inSubtree=true) exists.
-
get
public Optional<V> get(List<K> ks, boolean any)
Retrieve value at given key. If any=true, returns any value in subtree rooted at key.
-
size
public int size()
Returns size (O(n) operation, traverses tree).
-
-