|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.boylesoftware.cb2.util.BTreeMap
This class allows to associate values with string prefixes. You add elements as to a map, where keys are strings and values are some objects, later you can do lookups by the longest prefix. Here is an example:
You have the folowing elements in your map:
ab => 1 abcd => 2 zyx => 3 zyxabc => 4
Below are results of lookups by various input strings:
abcdefgh => 2 abc => 1 a => null orange => null zyx => 3 zyx_111 => 3
This implementation is not thread-safe. In multithread environments access an object of this class has to be synchronized externally.
| Nested Class Summary | |
protected class |
BTreeMap.Entry
An entry. |
| Field Summary | |
protected java.util.HashMap |
top
The top level. |
| Constructor Summary | |
BTreeMap()
Constructs a new empty map. |
|
| Method Summary | |
void |
clear()
Clears the map. |
protected void |
clear(java.util.HashMap level)
Clears one level. |
java.lang.Object |
get(java.lang.String key)
Looks up the best value for the specified key. |
void |
put(java.lang.String prefix,
java.lang.Object value)
Adds a new value to the map. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected final java.util.HashMap top
Character,
values are objects of BTreeMap.Entry.
| Constructor Detail |
public BTreeMap()
| Method Detail |
public void put(java.lang.String prefix,
java.lang.Object value)
prefix - the key.value - the value.public java.lang.Object get(java.lang.String key)
key - the input key to look up a value for.
null.public void clear()
protected void clear(java.util.HashMap level)
level - the level.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||