new ArrayMap(keys, values)
Hash table based implementation of the Map interface.
Hash table based implementation of the Map interface.
Note: this class is the ArrayMap class in the AS3 version of VEGAS.
Parameters:
| Name | Type | Description |
|---|---|---|
keys |
array | An optional |
values |
array | An optional |
Example
var map = new ArrayMap() ;
map.set("key1", "value1") ;
map.set("key2", "value2") ;
map.set("key3", "value3") ;
trace ("map : " + map) ;
trace ("------ iterator") ;
var it = map.iterator() ;
while (it.hasNext())
{
trace (it.next() + " : " + it.key()) ;
}
trace( 'values : ' + map.values()) ;
trace( map.has('key2')) ;
trace( map.get('key2') ) ;
trace( map.indexOfKey('key2')) ;
map.delete( 'key2' ) ;
trace ("map : " + map) ;
Extends
Members
-
<readonly> length :number
-
The number of key-value mappings in this map.
Type:
- number
- Overrides:
Methods
-
clear()
-
Removes all mappings from this map (optional operation).
- Overrides:
-
clone()
-
Returns a shallow copy of this ArrayMap instance: the keys and values themselves are not cloned.
- Overrides:
Returns:
a shallow copy of this ArrayMap instance: the keys and values themselves are not cloned.
-
delete(key)
-
Removes the mapping for this key from this map if present.
Parameters:
Name Type Description key* The key whose mapping is to be removed from the map.
- Overrides:
Returns:
previous value associated with specified key, or null if there was no mapping for key. A
nullreturn can also indicate that the map previously associated null with the specified key. -
forEach(callback, thisArg)
-
The forEach() method executes a provided function once per each key/value pair in the Map object, in insertion order.
Parameters:
Name Type Description callbackfunction Function to execute for each element.
thisArgObject Value to use as this when executing callback.
- Overrides:
-
get(key)
-
Returns the value to which this map maps the specified key.
Parameters:
Name Type Description key* The key of the entry to retrieve in the collection.
- Overrides:
Returns:
the value to which this map maps the specified key.
-
getKeyAt(index)
-
Returns the value to which this map maps the specified key.
Parameters:
Name Type Description indexnumber The index of the key in the array map.
Returns:
the value to which this map maps the specified key.
-
getValueAt(index)
-
Returns the value to which this map maps the specified key.
Parameters:
Name Type Description indexnumber The index of the value in the array map.
Returns:
the value to which this map maps the specified key.
-
has(key)
-
Returns
trueif this map contains a mapping for the specified key.Parameters:
Name Type Description key* The key of the entry to retrieve in the collection.
- Overrides:
-
hasValue()
-
Returns
trueif this map maps one or more keys to the specified value.- Overrides:
Returns:
trueif this map maps one or more keys to the specified value. -
indexOfKey(key)
-
Returns the index of the specified key in argument.
Parameters:
Name Type Description key* The key in the map to search.
Returns:
The index of the specified key in argument.
-
indexOfValue(value)
-
Returns the index of the specified value in argument.
Parameters:
Name Type Description value* The value in the map to search.
Returns:
the index of the specified value in argument.
-
isEmpty()
-
Returns
trueif this map contains no key-value mappings.- Overrides:
Returns:
trueif this map contains no key-value mappings. -
iterator()
-
Returns the values iterator of this map.
- Overrides:
Returns:
the values iterator of this map.
-
keyIterator()
-
Returns the keys iterator of this map.
- Overrides:
Returns:
the keys iterator of this map.
-
keys()
-
Returns an array representation of all keys in the map.
- Overrides:
Returns:
an array representation of all keys in the map.
-
set(key, value)
-
Associates the specified value with the specified key in this map.
Parameters:
Name Type Description key* The key to register the value.
value* The value to be mapped in the map.
- Overrides:
-
setAll(map)
-
Copies all of the mappings from the specified map to this one.
Parameters:
Name Type Description mapsystem.data.KeyValuePair The map to fill the current map.
- Overrides:
-
setKeyAt(index, key)
-
Sets the value of the
"key"in theArrayMapwith the specified index.Parameters:
Name Type Description indexnumber The position of the entry in the ArrayMap.
key* The key of the entry to change.
Throws:
RangeError If the index is out of the range of the Map size.
Returns:
A
MapEntrywho corresponding the old key/value entry or null if the key already exist or the specified index don't exist. -
setValueAt(index, value)
-
Sets the value of the "value" in the HashMap (ArrayMap) with the specified index.
Parameters:
Name Type Description indexnumber The position of the entry in the ArrayMap.
value* The value of the entry to change.
Returns:
A
MapEntrywho corresponding the old key/value entry or null if the key already exist or the specified index don't exist. -
toString()
-
Returns the string representation of this map.
- Overrides:
Returns:
the string representation of this map.
-
values()
-
Returns an array representation of all values in the map.
- Overrides:
Returns:
an array representation of all values in the map.