Packagesystem.data.maps
Classpublic dynamic class HashMap
InheritanceHashMap Inheritance Object
Implements Map

Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key.

This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.

Example :

     import system.data.Map ;
     import system.data.maps.HashMap;
     import system.data.iterator.Iterator;
     
     var map:Map = new HashMap() ;
     
     trace("put key1 -> value0 : " + map.put("key1", "value0") ) ;
     trace("put key1 -> value1 : " + map.put("key1", "value1") ) ;
     trace("put key2 -> value2 : " + map.put("key2", "value2") ) ;
     trace("put key3 -> value3 : " + map.put("key3", "value3") ) ;
     
     trace("map : " + map) ;
     
     trace("--- clone") ;
     
     var clone:Map = map.clone() ;
     trace("clone : " + clone) ;
     
     trace("--- map toSource") ;
     
     trace("map toSource : " + map.toSource()) ;
     
     trace("--- iterator") ;
     
     var it:Iterator = map.iterator() ;
     while( it.hasNext() )
     {
         var v:= it.next() ;
         var k:= it.key() ;
         trace( "   -> " + k + " : " + v ) ;
     }
     
     trace("--- dynamic insertion ") ;
     
     map["key4"] = "value4" ; // dynamic insertion
     
     trace("map : " + map) ;
     
     trace("--- use delete") ;
     
     delete map["key4"] ;
     
     trace(" map : " + map) ;
     
     trace("--- remove 'key1'") ;
     
     trace("remove key1 : " + (delete map["key1"]) ) ; //.remove("key1")) ;
     
     trace("size : " + map.size()) ;
     
     trace("map : " + map) ;
     
     trace("--- clear and isEmpty") ;
     
     map.clear() ;
     
     trace("isEmpty : " + map.isEmpty()) ;  
     



Public Methods
 MethodDefined By
  
HashMap(... arguments)
Creates a new HashMap instance.
HashMap
  
clear():void
Removes all mappings from this map.
HashMap
  
clone():*
Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
HashMap
  
containsKey(key:*):Boolean
Returns true if this map contains a mapping for the specified key.
HashMap
  
containsValue(value:*):Boolean
Returns true if this map maps one or more keys to the specified value.
HashMap
  
get(key:*):*
Returns the value to which this map maps the specified key.
HashMap
  
getKeys():Array
Returns an array representation of all keys in the map.
HashMap
  
getValues():Array
Returns an array representation of all values in the map.
HashMap
  
isEmpty():Boolean
Returns true if this map contains no key-value mappings.
HashMap
  
Returns the values iterator of this map.
HashMap
  
Returns the keys iterator of this map.
HashMap
  
put(key:*, value:*):*
Associates the specified value with the specified key in this map.
HashMap
  
putAll(m:Map):void
Copies all of the mappings from the specified map to this one.
HashMap
  
remove(o:*):*
Removes the mapping for this key from this map if present.
HashMap
  
size():uint
Returns the number of key-value mappings in this map.
HashMap
  
toSource(indent:int = 0):String
Returns the source representation of the object.
HashMap
  
toString():String
Returns the String representation of this map.
HashMap
Constructor Detail
HashMap()Constructor
public function HashMap(... arguments)

Creates a new HashMap instance.

Parameters
... arguments
Method Detail
clear()method
public function clear():void

Removes all mappings from this map.

clone()method 
public function clone():*

Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.

Returns
* — a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
containsKey()method 
public function containsKey(key:*):Boolean

Returns true if this map contains a mapping for the specified key.

Parameters

key:*

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

Returns true if this map maps one or more keys to the specified value.

Parameters

value:*

Returns
Boolean — true if this map maps one or more keys to the specified value.
get()method 
public function get(key:*):*

Returns the value to which this map maps the specified key.

Parameters

key:*

Returns
* — the value to which this map maps the specified key.
getKeys()method 
public function getKeys():Array

Returns an array representation of all keys in the map.

Returns
Array — an array representation of all keys in the map.
getValues()method 
public function getValues():Array

Returns an array representation of all values in the map.

Returns
Array — an array representation of all values in the map.
isEmpty()method 
public function isEmpty():Boolean

Returns true if this map contains no key-value mappings.

Returns
Boolean — true if this map contains no key-value mappings.
iterator()method 
public function iterator():Iterator

Returns the values iterator of this map.

Returns
Iterator — the values iterator of this map.
keyIterator()method 
public function keyIterator():Iterator

Returns the keys iterator of this map.

Returns
Iterator — the keys iterator of this map.
put()method 
public function put(key:*, value:*):*

Associates the specified value with the specified key in this map.

Parameters

key:*
 
value:*

Returns
*
putAll()method 
public function putAll(m:Map):void

Copies all of the mappings from the specified map to this one.

Parameters

m:Map

remove()method 
public function remove(o:*):*

Removes the mapping for this key from this map if present.

Parameters

o:* — The key whose mapping is to be removed from the map.

Returns
* — previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
size()method 
public function size():uint

Returns the number of key-value mappings in this map.

Returns
uint — the number of key-value mappings in this map.
toSource()method 
public function toSource(indent:int = 0):String

Returns the source representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source representation of the object.
toString()method 
public function toString():String

Returns the String representation of this map.

Returns
String — the String representation of this map.