Packageorg.spicefactory.lib.collection
Classpublic class Map
InheritanceMap Inheritance Object

Simple Map implementation that overcomes the limitations of the Flash Dictionary API which lacks essential methods and properties like size/length. Within the Spicefactory libraries and frameworks these collections are usually only used inside the implementations, but not exposed in the public APIs.

Due to limitations in the Flash Proxy class which only accepts String-based keys, the Map class does not support for and for each loops or bracket access for reading and writing values. For loops you can loop over Map.keys or Map.values instead.



Public Properties
 PropertyDefined By
  keys : List
[read-only] All keys of this map in no particular oder.
Map
  values : List
[read-only] All values of this map in no particular order.
Map
Public Methods
 MethodDefined By
  
Map(dictionary:Dictionary = null)
Creates a new instance.
Map
  
Clones this map.
Map
  
containsKey(key:Object):Boolean
Indicates whether this map contains a value mapped to the specified key.
Map
  
containsValue(value:*):Boolean
Indicates whether this map contains the specified value at least once.
Map
  
get(key:Object):*
Returns the value mapped to the specified key or undefined.
Map
  
isEmpty():Boolean
Indicates whether this map is empty.
Map
  
put(key:Object, value:*):*
Adds a value for the specified key.
Map
  
remove(key:Object):*
Removes and returns the value mapped to the specified key.
Map
  
removeAll():void
Removes all keys and values from this map.
Map
  
size():uint
Returns the number of items in this map.
Map
  
toDictionary():Dictionary
Returns this map as a Dictionary.
Map
Property Detail
keysproperty
keys:List  [read-only]

All keys of this map in no particular oder.


Implementation
    public function get keys():List
valuesproperty 
values:List  [read-only]

All values of this map in no particular order.


Implementation
    public function get values():List
Constructor Detail
Map()Constructor
public function Map(dictionary:Dictionary = null)

Creates a new instance.

Parameters
dictionary:Dictionary (default = null) — the dictionry to initially populate the map with
Method Detail
clone()method
public function clone():Map

Clones this map. Modifications in the clone are not reflected in the original map and vice versa.

Returns
Map — a clone of this map
containsKey()method 
public function containsKey(key:Object):Boolean

Indicates whether this map contains a value mapped to the specified key.

Parameters

key:Object — the key to check

Returns
Boolean — true if this map contains a value mapped to the specified key
containsValue()method 
public function containsValue(value:*):Boolean

Indicates whether this map contains the specified value at least once.

Parameters

value:* — the value to check

Returns
Boolean — true if this map contains the specified value at least once
get()method 
public function get(key:Object):*

Returns the value mapped to the specified key or undefined.

Parameters

key:Object — the key to return the mapped value for

Returns
* — the value mapped to the specified key or undefined
isEmpty()method 
public function isEmpty():Boolean

Indicates whether this map is empty.

Returns
Boolean — true if this map does not contain any items.
put()method 
public function put(key:Object, value:*):*

Adds a value for the specified key. If there was already a value mapped for this key, this method will remove it from the map and return it. Otherwise this method returns undefined.

Parameters

key:Object — the key to map the value to
 
value:* — the value to add

Returns
* — the value previously mapped to the key or undefined
remove()method 
public function remove(key:Object):*

Removes and returns the value mapped to the specified key.

Parameters

key:Object — the key to remove from the map

Returns
* — the value previously mapped to the specified key or undefined
removeAll()method 
public function removeAll():void

Removes all keys and values from this map.

size()method 
public function size():uint

Returns the number of items in this map.

Returns
uint — the number of items in this map
toDictionary()method 
public function toDictionary():Dictionary

Returns this map as a Dictionary.

Returns
Dictionary — this map as a Dictionary