V
- value typepublic class PatriciaTrie<V>
extends java.lang.Object
implements java.util.Map<java.lang.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(java.lang.Object key)
Test membership in this trie
|
boolean |
containsKeyPrefix(java.lang.String prefix)
Test key prefix membership in this trie (prefix search using key)
|
boolean |
containsValue(java.lang.Object value)
Predicate to test value membership
|
java.util.Set<java.util.Map.Entry<java.lang.String,V>> |
entrySet()
Returns a copy of the mappings contained in this trie as a Set
|
V |
get(java.lang.Object key)
Get value associated with specified key in this trie
|
PatriciaTrie.KeyMapper<java.lang.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
|
java.util.Set<java.lang.String> |
keySet()
Returns a copy of the keys contained in this trie as a Set
|
V |
put(java.lang.String key,
V value)
Puts value into trie identifiable by key into this trie (key should be non-null)
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends V> map)
Inserts all key and value entries in a map into this trie
|
V |
remove(java.lang.Object key)
Removes entry identified by key from this trie (currently unsupported)
|
int |
size()
Returns the number of key-value mappings in this trie
|
java.util.Collection<V> |
values()
Returns a copy of the values contained in this trie as a Set
|
protected PatriciaTrie.PatriciaNode<V> root
protected int entries
public V get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,V>
key
- key to retrieve value forpublic V put(java.lang.String key, V value)
put
in interface java.util.Map<java.lang.String,V>
key
- key to associate with valuevalue
- value be insertedjava.lang.NullPointerException
- in case key is nullpublic void putAll(java.util.Map<? extends java.lang.String,? extends V> map)
putAll
in interface java.util.Map<java.lang.String,V>
map
- map with entries to insertpublic V remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,V>
key
- to removejava.lang.UnsupportedOperationException
- is always thrown since this operation is unimplementedpublic boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,V>
key
- to test if existspublic java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,V>
public java.util.Collection<V> values()
values
in interface java.util.Map<java.lang.String,V>
public boolean containsKeyPrefix(java.lang.String prefix)
prefix
- key prefix to searchpublic int size()
size
in interface java.util.Map<java.lang.String,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,V>
public void clear()
clear
in interface java.util.Map<java.lang.String,V>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,V>
value
- value to test if is contained in the triepublic java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,V>
public PatriciaTrie.PatriciaNode<V> getRoot()
PatriciaTrieFormatter
public PatriciaTrie.KeyMapper<java.lang.String> getKeyMapper()
PatriciaTrieFormatter