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".
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private String | |
| private int | |
| private V |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| private void | |
| private static char[] | |
| public boolean | Returns: true if key is present in the mapkey to look up key)Implements joptsimple. 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. |
| public V | Returns: the value associated withaKey; or null if there is no
such value or aKey is not a unique abbreviation of a key in the mapkey to look up key)Implements joptsimple. Answers the value associated with the given key. |
| public void | put(String
key to create in the map key, V value to associate with the key newValue)Implements joptsimple. Associates a given value with a given key. |
| public void | putAll(Iterable<String>
keys to create in the map keys, V value to associate with the key newValue)Implements joptsimple. Associates a given value with a given set of keys. |
| public void | remove(String
key to remove key)Implements joptsimple. If the map contains the given key, dissociates the key from its value. |
| private boolean | |
| private boolean | |
| private void | |
| public Map | Returns: a Java map corresponding to this abbreviation mapImplements joptsimple. |
| children | back to summary |
|---|---|
| private final Map<Character, AbbreviationMap<V>> children | |
| key | back to summary |
|---|---|
| private String key | |
| keysBeyond | back to summary |
|---|---|
| private int keysBeyond | |
| value | back to summary |
|---|---|
| private V value | |
| AbbreviationMap | back to summary |
|---|---|
| public AbbreviationMap() | |
| add | back to summary |
|---|---|
| private boolean add(char[] chars, V newValue, int offset, int length) | |
| addToMappings | back to summary |
|---|---|
| private void addToMappings(Map<String, V> mappings) | |
| charsOf | back to summary |
|---|---|
| private static char[] charsOf(String aKey) | |
| contains | back to summary |
|---|---|
| public boolean contains(String key) Implements joptsimple. 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.
| |
| get | back to summary |
|---|---|
| public V get(String key) Implements joptsimple. Answers the value associated with the given key. The key can be a unique abbreviation of a key that is in the map.
| |
| put | back to summary |
|---|---|
| public void put(String key, V newValue) Implements joptsimple. Associates a given value with a given key. If there was a previous association, the old value is replaced with the new one.
| |
| putAll | back to summary |
|---|---|
| public void putAll(Iterable<String> keys, V newValue) Implements joptsimple. 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.
| |
| remove | back to summary |
|---|---|
| public void remove(String key) Implements joptsimple. If the map contains the given key, dissociates the key from its value.
| |
| remove | back to summary |
|---|---|
| private boolean remove(char[] aKey, int offset, int length) | |
| removeAtEndOfKey | back to summary |
|---|---|
| private boolean removeAtEndOfKey() | |
| setValueToThatOfOnlyChild | back to summary |
|---|---|
| private void setValueToThatOfOnlyChild() | |
| toJavaUtilMap | back to summary |
|---|---|
| public Map Implements joptsimple. Gives a Java map representation of this abbreviation map. | |