|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjoptsimple.internal.AbbreviationMap<V>
V - a constraint on the types of the values in the mappublic class AbbreviationMap<V>
A map whose keys are strings; when a key/value pair is added to the map, the longest unique abbreviations of that key are added as well, and associated with the value. Thus:
abbreviations.put( "good", "bye" );
would make it such that you could retrieve the value "bye" from the map using the keys "good",
"goo", "go", and "g". A subsequent invocation of:
abbreviations.put( "go", "fish" );
would make it such that you could retrieve the value "bye" using the keys "good" and
"goo", and the value "fish" using the key "go". The key "g" would yield
null, since it would no longer be a unique abbreviation.
The data structure is much like a "trie".
| Constructor Summary | |
|---|---|
AbbreviationMap()
|
|
| Method Summary | |
|---|---|
boolean |
contains(String aKey)
Tells whether the given key is in the map, or whether the given key is a unique abbreviation of a key that is in the map. |
V |
get(String aKey)
Answers the value associated with the given key. |
void |
put(String aKey,
V newValue)
Associates a given value with a given key. |
void |
putAll(Iterable<String> keys,
V newValue)
Associates a given value with a given set of keys. |
void |
remove(String aKey)
If the map contains the given key, dissociates the key from its value. |
Map<String,V> |
toJavaUtilMap()
Gives a Java map representation of this abbreviation map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbbreviationMap()
| Method Detail |
|---|
public boolean contains(String aKey)
Tells whether the given key is in the map, or whether the given key is a unique abbreviation of a key that is in the map.
aKey - key to look up
true if key is present in the map
NullPointerException - if key is nullpublic V get(String aKey)
Answers the value associated with the given key. The key can be a unique abbreviation of a key that is in the map.
aKey - key to look up
aKey; or null if there is no
such value or aKey is not a unique abbreviation of a key in the map
NullPointerException - if aKey is null
public void put(String aKey,
V newValue)
Associates a given value with a given key. If there was a previous association, the old value is replaced with the new one.
aKey - key to create in the mapnewValue - value to associate with the key
NullPointerException - if aKey or newValue is null
IllegalArgumentException - if aKey is a zero-length string
public void putAll(Iterable<String> keys,
V newValue)
Associates a given value with a given set of keys. If there was a previous association, the old value is replaced with the new one.
keys - keys to create in the mapnewValue - value to associate with the key
NullPointerException - if keys or newValue is null
IllegalArgumentException - if any of keys is a zero-length stringpublic void remove(String aKey)
If the map contains the given key, dissociates the key from its value.
aKey - key to remove
NullPointerException - if aKey is null
IllegalArgumentException - if aKey is a zero-length stringpublic Map<String,V> toJavaUtilMap()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||