K - The type of the key in the association.V - The type of the value in the association.public class Map<K,V> extends SortableCollection<Association<K,V>> implements Associative<K,V>
| Constructor and Description |
|---|
Map()
This constructor creates a new empty map.
|
Map(Iteratable<K> keys,
Iteratable<V> values)
This constructor creates a new map using the specified keys and values.
|
Map(K[] keys,
V[] values)
This constructor creates a new map using the specified key and value arrays.
|
Map(Map<K,V> elements)
This constructor creates a new map using the elements provided in the specified map.
|
Map(java.util.Map<K,V> elements)
This constructor creates a new map using the elements provided in a java map.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addElement(Association<K,V> element)
This method adds a new element to the collection.
|
void |
associateKeyWithValue(K key,
V value)
This method associates in this collection a new value with a key.
|
static <K,V> Map<K,V> |
concatenate(Map<K,V> map1,
Map<K,V> map2)
This function returns a new map that contains the all the associations from
both the specified maps.
|
boolean |
containsElement(Association<K,V> element)
This method determines if an element is contained in the collection.
|
Iterator<Association<K,V>> |
createDefaultIterator()
This method creates a new default iterator for the collection.
|
Manipulator<Association<K,V>> |
createDefaultManipulator()
This method creates a new default manipulator for the collection.
|
Iteratable<Association<K,V>> |
getAssociations()
This method returns the list of associations between keys and values for this collection.
|
Iteratable<? super K> |
getKeys()
This method returns the list of keys for the associations in this collection.
|
int |
getNumberOfElements() |
V |
getValueForKey(K key)
This method returns the value associated with the specified key.
|
Iteratable<? super V> |
getValues()
This method returns the list of values for the associations in this collection.
|
static <K,V> Map<K,V> |
reduce(Map<K,V> map,
Set<K> keys)
This function returns a new map that contains only the associations with
the specified keys.
|
void |
removeAllElements()
This method removes all elements from the collection.
|
boolean |
removeElement(Association<K,V> element)
This method removes the specified element from the collection.
|
V |
removeValueForKey(K key)
This method removes from this collection the value associated with a key.
|
concatenate, sortElements, sortElements, sorteraddElements, addElements, containsAllElementsIn, containsAnyElementsIn, equals, hashCode, isEmpty, iterator, normalizedIndex, removeElements, removeElements, toArray, toString, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitisEmpty, iterator, toArraypublic Map()
public Map(K[] keys, V[] values)
keys - The array of keys that should be used to create the map.values - The array of values that should be used to create the map.public Map(Iteratable<K> keys, Iteratable<V> values)
keys - The keys that should be used to create the map.values - The values that should be used to create the map.public Map(Map<K,V> elements)
elements - The map containing the key-value pairs to be mapped.public final int getNumberOfElements()
getNumberOfElements in interface Sequential<Association<K,V>>public final boolean containsElement(Association<K,V> element)
AccessiblecontainsElement in interface Accessible<Association<K,V>>element - The element to be checked for in the collection.public Iterator<Association<K,V>> createDefaultIterator()
IteratablecreateDefaultIterator in interface Iteratable<Association<K,V>>public final boolean addElement(Association<K,V> element)
AccessibleaddElement in interface Accessible<Association<K,V>>element - The new element to be added.public final boolean removeElement(Association<K,V> element)
AccessibleremoveElement in interface Accessible<Association<K,V>>element - The element to be removed.public final void removeAllElements()
IteratableremoveAllElements in interface Iteratable<Association<K,V>>public Manipulator<Association<K,V>> createDefaultManipulator()
SortablecreateDefaultManipulator in interface Sortable<Association<K,V>>public final Iteratable<? super K> getKeys()
AssociativegetKeys in interface Associative<K,V>public final Iteratable<? super V> getValues()
AssociativegetValues in interface Associative<K,V>public final Iteratable<Association<K,V>> getAssociations()
AssociativegetAssociations in interface Associative<K,V>public final V getValueForKey(K key)
AssociativegetValueForKey in interface Associative<K,V>key - The key for the value to be retrieved.public final void associateKeyWithValue(K key, V value)
AssociativeassociateKeyWithValue in interface Associative<K,V>key - The key for the new value.value - The new value to be associated with the key.public final V removeValueForKey(K key)
Associativenull is returned.removeValueForKey in interface Associative<K,V>key - The key for the value to be removed.public static <K,V> Map<K,V> concatenate(Map<K,V> map1, Map<K,V> map2)
K - The type of key contained in the maps.V - The type of value contained in the maps.map1 - The first map whose elements are to be added.map2 - The second map whose elements are to be added.public static <K,V> Map<K,V> reduce(Map<K,V> map, Set<K> keys)
K - The type of key contained in the maps.V - The type of value contained in the maps.map - The map whose elements are to be reduced.keys - The set of keys for the associates to be saved.Copyright © 2014 Crater Dog Technologies(TM). All rights reserved.