Collection of key-value pairs where the keys are of the String
data type and the values are of the declaration type. The keys are unique for each value.
PUBLIC METHODS
Integer size()
It returns the total number of pairs in the collection.
Return |
|
Integer |
Number of pairs. |
T get(String clave)
It returns the associated element to the parameter key. The collection and its size are not modified. If the key is not found, an exception is thrown.
Arguments |
|
key |
String: key of the desired element. |
Return |
|
T |
Associated element. |
Exceptions |
CollectionKeyNotFound – Has not found a value for key ‘clave’. |
T get(String clave, T valorPorDefecto)
It returns the associated element to the parameter key. The collection and its size are not modified. If the key is not found, the “value by default” considered as argument returns.
Arguments |
|
key |
String: key of the desired element. |
Return |
|
T |
Element associated with “key” or “valuebydefault” considered as argument. |
void remove(String clave)
It removes the element associated with the parameter key. After removing the element, the size of the collection decreases by one. If the key is not found, no modification is carried out.
Arguments |
|
key |
String: key of the element that we want to remove. |
void removeAll()
It removes all the elements of the map. The size of the map is zero.
Map<T> clone()
It creates a new instance of a map with the same number of elements. Each element and keys are new references of true copies of the elements from the original map.
Return |
|
Map<T> |
New instance with the same content of the original array. |
Boolean hasKey(String clave)
It returns true if the element associated with the parameter key is found. Otherwise, it returns false.
Return |
|
Boolean |
Existence of an element for a key. |
Array<String> keys()
It returns an array with all the keys of the pairs it contains.
Array<T> values()
It returns an array with all the values of the pairs it contains.
Return |
|
Array<T> |
Element list. |
void set(String clave, T elemento)
It adds the parameter element to the map and associates it with the key. If the key has an associated element already, then it replaces it.
Arguments |
|
key |
String: key to replace or add. |
element |
T: element. |
Exceptions |
TypeMismatchInAddInCollection – Type mismatch adding an element value of different type in a collection. |