org.apache.pivot.collections
Interface Dictionary<K,V>

All Known Subinterfaces:
Map<K,V>
All Known Implementing Classes:
BeanAdapter, Element.ElementDictionary, Element.NamespaceDictionary, EnumMap, HashMap, ImmutableMap, MapAdapter, MIMEType, Resources, SynchronizedMap

public interface Dictionary<K,V>

Interface representing a set of key/value pairs.


Nested Class Summary
static class Dictionary.Pair<K,V>
          Class representing a key/value pair.
 
Method Summary
 boolean containsKey(K key)
          Tests the existence of a key in the dictionary.
 V get(K key)
          Retrieves the value for the given key.
 V put(K key, V value)
          Sets the value of the given key, creating a new entry or replacing the existing value.
 V remove(K key)
          Removes a key/value pair from the map.
 

Method Detail

get

V get(K key)
Retrieves the value for the given key.

Parameters:
key - The key whose value is to be returned.
Returns:
The value corresponding to key, or null if the key does not exist. Will also return null if the key refers to a null value. Use containsKey() to distinguish between these two cases.

put

V put(K key,
      V value)
Sets the value of the given key, creating a new entry or replacing the existing value.

Parameters:
key - The key whose value is to be set.
value - The value to be associated with the given key.
Returns:
The value previously associated with the key.

remove

V remove(K key)
Removes a key/value pair from the map.

Parameters:
key - The key whose mapping is to be removed.
Returns:
The value that was removed.

containsKey

boolean containsKey(K key)
Tests the existence of a key in the dictionary.

Parameters:
key - The key whose presence in the dictionary is to be tested.
Returns:
true if the key exists in the dictionary; false, otherwise.