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(Collection<K> keys,
Collection<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.
|
Map<K,V> |
copy() |
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.
|
List<Association<K,V>> |
getAssociations()
This method returns the list of associations between keys and values for this collection.
|
Association<K,V> |
getElementAtIndex(int index)
This method returns the element at the specified index.
|
List<Association<K,V>> |
getElementsInRange(int firstIndex,
int lastIndex)
This method returns a collection of the elements in the specified index range.
|
int |
getIndexOfElement(Association<K,V> element)
This method return the index of the specified element, or zero if the element
is not found.
|
List<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.
|
List<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.
|
java.util.LinkedHashMap<K,V> |
toMap() |
concatenate, shuffleElements, sortElements, sortElements, sortElementsaddElements, addElements, removeElements, removeElementscompareTo, containsAllElementsIn, containsAnyElementsIn, equals, hashCode, isEmpty, iterator, normalizedIndex, toArrayaddSerializableClass, addSerializableClass, toExposedString, toString, toStringpublic 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(Collection<K> keys, Collection<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 Map<K,V> copy()
copy in class craterdog.smart.SmartObject<Collection<Association<K,V>>>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>>containsElement in class Collection<Association<K,V>>element - The element to be checked for in the collection.public Iterator<Association<K,V>> createDefaultIterator()
AccessiblecreateDefaultIterator in interface Accessible<Association<K,V>>public final Association<K,V> getElementAtIndex(int index)
AccessiblegetElementAtIndex in interface Accessible<Association<K,V>>index - The index of the element to be returned.public final int getIndexOfElement(Association<K,V> element)
AccessiblegetIndexOfElement in interface Accessible<Association<K,V>>element - The element to be checked for in the collection.public final List<Association<K,V>> getElementsInRange(int firstIndex, int lastIndex)
AccessiblegetElementsInRange in interface Accessible<Association<K,V>>firstIndex - The index of the first element to be returned.lastIndex - the index of the last element to be returned.public final boolean addElement(Association<K,V> element)
DynamicaddElement in interface Dynamic<Association<K,V>>element - The new element to be added.public final boolean removeElement(Association<K,V> element)
DynamicremoveElement in interface Dynamic<Association<K,V>>element - The element to be removed.public final void removeAllElements()
AccessibleremoveAllElements in interface Accessible<Association<K,V>>public Manipulator<Association<K,V>> createDefaultManipulator()
SortablecreateDefaultManipulator in interface Sortable<Association<K,V>>public final List<K> getKeys()
AssociativegetKeys in interface Associative<K,V>public final List<V> getValues()
AssociativegetValues in interface Associative<K,V>public final List<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 © 2015 Crater Dog Technologies(TM). All rights reserved.