V
- value typepublic class PatriciaTrie<V> extends Object implements Map<String,V>
Implements the Map<String, V>
interface
Note that values()
, keySet()
, entrySet()
and containsValue()
have naive implementations
Modifier and Type | Class and Description |
---|---|
static interface |
PatriciaTrie.KeyMapper<K>
Generic interface to map a key to bits
|
static class |
PatriciaTrie.PatriciaNode<V>
Nodes used in a
PatriciaTrie containing a String key and associated value data |
static class |
PatriciaTrie.StringKeyMapper
A
PatriciaTrie.KeyMapper mapping Strings to bits |
Modifier and Type | Field and Description |
---|---|
protected int |
entries
Number of entries in the trie
|
protected PatriciaTrie.PatriciaNode<V> |
root
Root value is left -- right is unused
|
Constructor and Description |
---|
PatriciaTrie()
Constructs and empty trie
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this trie by removing all its key-value pairs
|
boolean |
containsKey(Object key)
Test membership in this trie
|
boolean |
containsKeyPrefix(String prefix)
Test key prefix membership in this trie (prefix search using key)
|
boolean |
containsValue(Object value)
Predicate to test value membership
|
Set<Map.Entry<String,V>> |
entrySet()
Returns a copy of the mappings contained in this trie as a Set
|
V |
get(Object key)
Get value associated with specified key in this trie
|
PatriciaTrie.KeyMapper<String> |
getKeyMapper()
Should only be used by
PatriciaTrieFormatter |
PatriciaTrie.PatriciaNode<V> |
getRoot()
Should only be used by
PatriciaTrieFormatter |
boolean |
isEmpty()
Predicate indicating whether this trie is empty
|
Set<String> |
keySet()
Returns a copy of the keys contained in this trie as a Set
|
V |
put(String key,
V value)
Puts value into trie identifiable by key into this trie (key should be non-null)
|
void |
putAll(Map<? extends String,? extends V> map)
Inserts all key and value entries in a map into this trie
|
V |
remove(Object key)
Removes entry identified by key from this trie (currently unsupported)
|
int |
size()
Returns the number of key-value mappings in this trie
|
Collection<V> |
values()
Returns a copy of the values contained in this trie as a Set
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
protected PatriciaTrie.PatriciaNode<V> root
protected int entries
public V put(String key, V value)
put
in interface Map<String,V>
key
- key to associate with valuevalue
- value be insertedNullPointerException
- in case key is nullpublic void putAll(Map<? extends String,? extends V> map)
public V remove(Object key)
remove
in interface Map<String,V>
key
- to removeUnsupportedOperationException
- is always thrown since this operation is unimplementedpublic boolean containsKey(Object key)
containsKey
in interface Map<String,V>
key
- to test if existspublic Collection<V> values()
public boolean containsKeyPrefix(String prefix)
prefix
- key prefix to searchpublic int size()
public boolean isEmpty()
public void clear()
public boolean containsValue(Object value)
containsValue
in interface Map<String,V>
value
- value to test if is contained in the triepublic Set<Map.Entry<String,V>> entrySet()
public PatriciaTrie.PatriciaNode<V> getRoot()
PatriciaTrieFormatter
public PatriciaTrie.KeyMapper<String> getKeyMapper()
PatriciaTrieFormatter
Copyright © 2020. All rights reserved.