Constructor
new AssociativeArray()
- Source:
Example
var aa = new MLJ.util.AssociativeArray();
aa.set("key1", obj1);
aa.set("key2", obj2);
var iter = aa.iterator();
var obj;
while(iter.hasNext()) {
obj = iter.next();
//do something with obj
}
Classes
Methods
getByKey(key)
Returns the value to which the specified key is mapped, or
undefined
if this array contains no mapping for the key
Parameters:
Name | Type | Description |
---|---|---|
key |
string | the key whose associated value is to be returned |
- Source:
Returns:
the value to which the specified key is mapped, or
undefined
if this array contains no mapping for the key
getFirst()
Returns the first inserted value of this associative array or
null
if the array is empty
- Source:
Returns:
the first inserted value or null
if the array is empty
getLast()
Returns the last inserted value of this associative array or
null
if the array is empty
- Source:
Returns:
the last inserted value or null
if the array is empty
iterator() → {MLJ.util.AssociativeArray._Iterator}
Returns an iterator over the elements in this array
- Source:
Returns:
- Type
- MLJ.util.AssociativeArray._Iterator
remove(key) → {Object}
Removes an element from this associative array
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key whose mapping is to be removed from the array |
- Source:
Returns:
The removed element if the array contains a mapping for
the key, null
otherwise
- Type
- Object
set(key, value)
Inserts an element in this associative array. Note that if the array previously contained a mapping for the key, the old value is replaced
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key with which the specified value is to be associated |
value |
Object | The value to be associated with the specified key |
- Source:
size() → {Integer}
Returns the number of elements in this array
- Source:
Returns:
The number of elements in this array
- Type
- Integer
sortByKey(order)
Sorts the items of the AssociativeArray
rearranging its keys
in ascending (default) or descending order.
Parameters:
Name | Type | Description |
---|---|---|
order |
String | The sort order: ascending ( |
- Source: