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

All Superinterfaces:
Collection<K>, Dictionary<K,V>, Iterable<K>
All Known Implementing Classes:
BeanAdapter, EnumMap, HashMap, ImmutableMap, MapAdapter, SynchronizedMap

public interface Map<K,V>
extends Dictionary<K,V>, Collection<K>

Collection interface representing set of key/value pairs.


Nested Class Summary
static class Map.MapListenerList<K,V>
          Map listener list.
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Dictionary
Dictionary.Pair<K,V>
 
Method Summary
 void clear()
          Removes all entries in the map.
 int getCount()
          Returns the number of entries in the map.
 ListenerList<MapListener<K,V>> getMapListeners()
          Returns the map listener collection.
 V put(K key, V value)
          Sets the value of the given key, creating a new entry or replacing the existing value, and firing a corresponding event.
 V remove(K key)
          Removes a key/value pair from the map.
 void setComparator(Comparator<K> comparator)
          Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.
 
Methods inherited from interface org.apache.pivot.collections.Dictionary
containsKey, get
 
Methods inherited from interface org.apache.pivot.collections.Collection
getComparator, isEmpty
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

put

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

Specified by:
put in interface Dictionary<K,V>
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.
See Also:
MapListener.valueAdded(Map, Object), MapListener.valueUpdated(Map, Object, Object)

remove

V remove(K key)
Description copied from interface: Dictionary
Removes a key/value pair from the map.

Specified by:
remove in interface Dictionary<K,V>
Parameters:
key - The key whose mapping is to be removed.
Returns:
The value that was removed.
See Also:
MapListener.valueRemoved(Map, Object, Object)

clear

void clear()
Removes all entries in the map.

Specified by:
clear in interface Collection<K>
See Also:
MapListener.mapCleared(Map)

getCount

int getCount()
Returns the number of entries in the map.


setComparator

void setComparator(Comparator<K> comparator)
Description copied from interface: Collection
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.

Calling this method more than once with the same comparator will re-sort the collection.

Specified by:
setComparator in interface Collection<K>
Parameters:
comparator - The comparator used to order elements in the collection, or null if the collection is unsorted.
See Also:
MapListener.comparatorChanged(Map, Comparator)

getMapListeners

ListenerList<MapListener<K,V>> getMapListeners()
Returns the map listener collection.