| Package | system.data.maps |
| Class | public class MultiValueMap |
| Inheritance | MultiValueMap Object |
| Implements | MultiMap |
| Subclasses | MultiSetMap |
MultiMap interface.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("key1" , "value1") ;
map.put("key1" , "value2") ;
map.put("key2" , "value3") ;
trace( map ) ;
| Property | Defined By | ||
|---|---|---|---|
| internalBuildClass : Class
Determinates the internal build class used in the createCollection() method to create a new collection to register all values with a new key. | MultiValueMap | ||
| Method | Defined By | ||
|---|---|---|---|
MultiValueMap(map:Map = null, factory:* = null)
Creates a new MultiValueMap instance. | MultiValueMap | ||
clear():void
Removes all elements in this map. | MultiValueMap | ||
clone():*
Returns a shallow copy of this object. | MultiValueMap | ||
containsKey(key:*):Boolean
Checks whether the map contains the key specified. | MultiValueMap | ||
containsValue(value:*):Boolean
Checks whether the map contains the value specified. | MultiValueMap | ||
containsValueByKey(key:*, value:*):Boolean
Checks whether the map contains the value specified or at the specified key contains the value. | MultiValueMap | ||
Creates a new instance of the map value Collection container. | MultiValueMap | ||
get(key:*):*
Gets the collection mapped to the specified key. | MultiValueMap | ||
getCollection(key:*):Collection
Gets the collection mapped to the specified key. | MultiValueMap | ||
getKeys():Array
Returns an Array containing the combination of all keys in the Map. | MultiValueMap | ||
getValues():Array
Returns an Array containing the combination of values from all keys. | MultiValueMap | ||
isEmpty():Boolean
Returns whether this object contains any mappings. | MultiValueMap | ||
Returns the Iterator representation of the object. | MultiValueMap | ||
iteratorByKey(key:*):Iterator
Gets an Iterator for the collection mapped to the specified key. | MultiValueMap | ||
Gets an iterator for the map to iterate keys. | MultiValueMap | ||
put(key:*, value:*):*
Adds the value to the collection associated with the specified key. | MultiValueMap | ||
Override superclass to ensure that MultiMap instances are correctly handled. | MultiValueMap | ||
putCollection(key:*, c:Collection):void
Adds a collection of values to the collection associated with the specified key. | MultiValueMap | ||
remove(o:*):*
Removes a specific value from map with a specific key. | MultiValueMap | ||
removeByKey(key:*, value:*):*
Removes a specific value from all the map. | MultiValueMap | ||
size():uint
Returns the size of the collection mapped to the specified key. | MultiValueMap | ||
toSource(indent:int = 0):String
Returns the source code string representation of the object. | MultiValueMap | ||
toString():String
Returns the string representation of this instance. | MultiValueMap | ||
totalSize():uint
Returns the total size of the map by counting all the values. | MultiValueMap | ||
Returns the iterator representation of all Collections register in the MultiValueMap, all collections represents a key. | MultiValueMap | ||
Returns a Collection of all values in the MultiValueMap. | MultiValueMap | ||
Returns an Iterator representation of all values in the MultiValueMap. | MultiValueMap | ||
| internalBuildClass | property |
internalBuildClass:ClassDeterminates the internal build class used in the createCollection() method to create a new collection to register all values with a new key. The class must implements the Collection interface and by default the ArrayCollection class is used.
public function get internalBuildClass():Class public function set internalBuildClass(value:Class):void| MultiValueMap | () | Constructor |
public function MultiValueMap(map:Map = null, factory:* = null)Creates a new MultiValueMap instance.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
Parameters map:Map (default = null) — Optional Map reference to initialize and fill this MultiMap.
| |
factory:* (default = null) — Optional Map reference to create the internal Map of the MultiValueMap
|
| clear | () | method |
public function clear():voidRemoves all elements in this map.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
map.clear() ;
trace( map ) ; // {}
| clone | () | method |
public function clone():*Returns a shallow copy of this object.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("keyA" , "itemA_1" ) ;
map.put("keyA" , "itemA_2" ) ;
map.put("keyB" , "itemB_2" ) ;
var clone:MultiValueMap = map.clone() ;
trace( clone ) ;
Returns* — a shallow copy of this object.
|
| containsKey | () | method |
public function containsKey(key:*):BooleanChecks whether the map contains the key specified.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello world" ) ;
trace( map.containsKey( "key1" ) ) ; // true
trace( map.containsKey( "key2" ) ) ; // false
Parameters
key:* |
Boolean — true if the Map contains the specified key.
|
| containsValue | () | method |
public function containsValue(value:*):BooleanChecks whether the map contains the value specified.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
trace( map.containsValue( "hello" ) ) ; // true
trace( map.containsValue( "bonjour" ) ) ; // true
trace( map.containsValue( "buenos dias" ) ) ; // false
Parameters
value:* |
Boolean — true if the List contains the specified value.
|
| containsValueByKey | () | method |
public function containsValueByKey(key:*, value:*):BooleanChecks whether the map contains the value specified or at the specified key contains the value.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
trace( map.containsValueByKey( "key1" , "hello" ) ) ; // true
trace( map.containsValueByKey( "key1" , "bonjour" ) ) ; // false
trace( map.containsValueByKey( "key2" , "hello" ) ) ; // false
trace( map.containsValueByKey( "key2" , "bonjour" ) ) ; // true
Parameters
key:* | |
value:* |
Boolean |
| createCollection | () | method |
public function createCollection():CollectionCreates a new instance of the map value Collection container. This method can be overridden to use your own collection type.
ReturnsCollection |
| get | () | method |
public function get(key:*):*Gets the collection mapped to the specified key.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
trace( map.get( "key1" ) ) ; // {hello}
trace( map.get( "key2" ) ) ; // {bonjour}
trace( map.get( "key3" ) ) ; // undefined
Parameters
key:* |
* |
| getCollection | () | method |
public function getCollection(key:*):CollectionGets the collection mapped to the specified key.
This method is a convenience method to typecast the result of get(key).
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
trace( map.getCollection( "key1" ) ) ; // {hello}
trace( map.getCollection( "key2" ) ) ; // {bonjour}
trace( map.getCollection( "key3" ) ) ; // null
Parameters
key:* |
Collection |
| getKeys | () | method |
public function getKeys():ArrayReturns an Array containing the combination of all keys in the Map.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "hello" ) ;
map.put( "key2" , "bonjour" ) ;
trace( map.getKeys() ) ; // key1,key2
ReturnsArray — An Array containing the combination of all keys in the Map.
|
| getValues | () | method |
public function getValues():ArrayReturns an Array containing the combination of values from all keys.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "A1" ) ;
map.put( "key2" , "B1" ) ;
map.put( "key2" , "B2" ) ;
map.put( "key3" , "C1" ) ;
trace( map.getValues() ) ; // no order if the internal Map is a HashMap (default)
ReturnsArray — An Array containing the combination of values from all keys.
|
| isEmpty | () | method |
public function isEmpty():BooleanReturns whether this object contains any mappings.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
trace( map.isEmpty() ) ; // true
map.put( "key" , "value" ) ;
trace( map.isEmpty() ) ; // false
ReturnsBoolean — true if this MultiHashSet contains any mappings else false
|
| iterator | () | method |
public function iterator():IteratorReturns the Iterator representation of the object.
ReturnsIterator — the Iterator representation of the object.
|
| iteratorByKey | () | method |
public function iteratorByKey(key:*):IteratorGets an Iterator for the collection mapped to the specified key.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("key1" , "value1") ;
map.put("key1" , "value2") ;
map.put("key2" , "value3") ;
trace( map.iteratorByKey( "key1" ) ) ; // [object ArrayIterator]
trace( map.iteratorByKey( "key3" ) ) ; // null
Parameters
key:* |
Iterator — the iterator of the collection at the key, null if key not in map
|
| keyIterator | () | method |
public function keyIterator():IteratorGets an iterator for the map to iterate keys.
ReturnsIterator |
| put | () | method |
public function put(key:*, value:*):*Adds the value to the collection associated with the specified key.
Unlike a normal Map the previous value is not replaced. Instead the new value is added to the collection stored against the key.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("keyA" , "itemA_1" ) ;
map.put("keyA" , "itemA_2" ) ;
map.put("keyB" , "itemB_2" ) ;
trace( map ) ; // {keyB:{itemB_2},keyA:{itemA_1,itemA_2}}
Parameters
key:* — the key to store against.
| |
value:* — the value to add to the collection at the key.
|
* — the value added if the map changed and null if the map did not change.
|
| putAll | () | method |
public function putAll(map:Map):voidOverride superclass to ensure that MultiMap instances are correctly handled.
If you call this method with a normal map, each entry is added using put(key:value:. If you call this method with a multi map, each entry is added using putCollection( key: co:Collection ).
Example :
import system.data.collections.ArrayCollection ;
import system.data.maps.ArrayMap ;
import system.data.maps.MultiValueMap ;
var am1:ArrayMap = new ArrayMap( [ "key1" , "key2" ] , ["value1" , "value2" ] ) ;
var am2:ArrayMap = new ArrayMap( [ "key1" ] , [ new ArrayCollection( [ "value3" ] ) ] ) ;
var mm:MultiValueMap = new MultiValueMap() ;
mm.putAll( am1 ) ; // {key2:{value2},key1:{value1}}
trace( mm ) ;
mm.putAll( am2 ) ; // {key2:{value2},key1:{value1,value3}}
trace( mm ) ;
Parameters
map:Map |
| putCollection | () | method |
public function putCollection(key:*, c:Collection):voidAdds a collection of values to the collection associated with the specified key.
Example :
import system.data.collections.ArrayCollection ;
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.putCollection( "key1" , new ArrayCollection(["value1", "value2"])) ;
map.putCollection( "key1" , new ArrayCollection(["value3", "value4"])) ;
map.putCollection( "key2" , new ArrayCollection(["value5"])) ;
trace( map ) ; // {key2:{value5},key1:{value1,value2,value3,value4}}
Parameters
key:* | |
c:Collection |
| remove | () | method |
public function remove(o:*):*Removes a specific value from map with a specific key.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("key1" , "value1") ;
map.put("key1" , "value2") ;
map.put("key2" , "value3") ;
trace( map.remove("key1") ) ; // {value1,value2}
Parameters
o:* — the key to remove in the map.
|
* |
| removeByKey | () | method |
public function removeByKey(key:*, value:*):*Removes a specific value from all the map.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put("key1" , "value1") ;
map.put("key1" , "value2") ;
map.put("key2" , "value3") ;
trace( map.removeByKey("key1" , "value1" ) ) ; // true
trace( map.removeByKey("key1" , "value5" ) ) ; // false
trace( map ) ; // {key2:{value3},key1:{value2}}
Parameters
key:* — the key to remove in the map
| |
value:* — (optional) if this value is defined removes a specific value from map else removes all values associated with the specified key.
|
* — the removed value.
|
| size | () | method |
public function size():uintReturns the size of the collection mapped to the specified key.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
trace( map.size() ) ; // 0
map.put( "key1" , "value1" ) ;
map.put( "key1" , "value2" ) ;
map.put( "key2" , "value3" ) ;
trace( map.size() ) ; // 2
Returnsuint — the size of the collection mapped to the specified key.
|
| toSource | () | method |
public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
public function toString():StringReturns the string representation of this instance.
ReturnsString — the string representation of this instance
|
| totalSize | () | method |
public function totalSize():uintReturns the total size of the map by counting all the values.
Example :
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
trace( map.totalSize() ) ; // 0
map.put( "key1" , "value1" ) ;
map.put( "key1" , "value2" ) ;
map.put( "key2" , "value3" ) ;
trace( map.totalSize() ) ; // 3
Returnsuint — the total size of the map by counting all the values.
|
| valueIterator | () | method |
public function valueIterator():IteratorReturns the iterator representation of all Collections register in the MultiValueMap, all collections represents a key.
Example :
import system.data.Iterator ;
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "A1" ) ;
map.put( "key2" , "B1" ) ;
map.put( "key2" , "B2" ) ;
map.put( "key3" , "C1" ) ;
var it:Iterator = map.valueIterator() ;
trace( it ) ;
while( it.hasNext() )
{
trace( it.next() ) ;
}
ReturnsIterator — the iterator representation of all Collections of values in the MultiValueMap.
|
| values | () | method |
public function values():CollectionReturns a Collection of all values in the MultiValueMap.
Example :
import system.data.Collection ;
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "A1" ) ;
map.put( "key2" , "B1" ) ;
map.put( "key2" , "B2" ) ;
map.put( "key3" , "C1" ) ;
var c:Collection = map.values() ;
trace( c ) ;
ReturnsCollection — a Collection of all values in the MultiValueMap.
|
| valuesIterator | () | method |
public function valuesIterator():IteratorReturns an Iterator representation of all values in the MultiValueMap.
import system.data.Iterator ;
import system.data.maps.MultiValueMap ;
var map:MultiValueMap = new MultiValueMap() ;
map.put( "key1" , "A1" ) ;
map.put( "key2" , "B1" ) ;
map.put( "key2" , "B2" ) ;
map.put( "key3" , "C1" ) ;
var it:Iterator = map.valuesIterator() ;
trace( it ) ;
while( it.hasNext() )
{
trace( it.next() ) ;
}
ReturnsIterator — an Iterator representation of all values in the MultiValueMap.
|