Package | com.ericfeminella.collections |
Class | public final class HashMap |
Implements | IMap |
Hashmap
instance has keys
and values added and retrieved.
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put("a", "value A"); map.put("b", "value B"); map.put("c", "value C"); map.put("x", "value X"); map.put("y", "value Y"); map.put("z", "value Z"); trace( map.getKeys() ); trace( map.getValues() ); trace( map.size() ); // outputs the following: // b,x,z,a,c,y // value B,value X,value Z,value A,value C,value Y // 6
See also
Method | Defined by | ||
---|---|---|---|
HashMap(useWeakReferences:Boolean = true)
Creates a new HashMap instance.
| HashMap | ||
clear():void
Resets all key / values in the HashMap instance to null
| HashMap | ||
clearAllExcept(keyId:*):void
Clears all key / values defined in the HashMap instance
with the exception of the specified key
| HashMap | ||
containsKey(key:*):Boolean
Determines if a key exists in the HashMap instance
| HashMap | ||
containsValue(value:*):Boolean
Determines if a value exists in the HashMap instance
| HashMap | ||
getEntries():IList
Returns an
IList of IHashMapEntry
objects based on the underlying internal map. | HashMap | ||
getKey(value:*):*
Returns a key value from the HashMap instance
| HashMap | ||
getKeys():Array
Returns each key added to the HashMap instance
| HashMap | ||
getValue(key:*):*
Retrieves the value of the specified key from the HashMap instance
| HashMap | ||
getValues():Array
Retrieves each value assigned to each key in the HashMap instance
| HashMap | ||
isEmpty():Boolean
Determines if the current HashMap instance is empty
| HashMap | ||
put(key:*, value:*):void
Adds a key and value to the HashMap instance
| HashMap | ||
putAll(table:Dictionary):void
[new]
putAll places all name / value pairs defined in an Object or Dictionary instance into the IMap instance. | HashMap | ||
putEntry(entry:IHashMapEntry):void
[new]
putEntry is intended as a pseudo-overloaded
put implementation whereby clients may call
putEntry to pass an IHashMapEntry
implementation. | HashMap | ||
remove(key:*):void
Removes a key and value from the HashMap instance
| HashMap | ||
reset():void
Resets all key value assignments in the HashMap instance to null
| HashMap | ||
resetAllExcept(keyId:*):void
Resets all key / values defined in the HashMap instance to null
with the exception of the specified key
| HashMap | ||
size():int
Determines the size of the HashMap instance
| HashMap |
HashMap | () | constructor |
public function HashMap(useWeakReferences:Boolean = true)
Creates a new HashMap instance. By default, weak key references are used in order to ensure that objects are eligible for Garbage Collection iimmediatly after they are no longer being referenced, if the only reference to an object is in the specified HashMap object, the key is eligible for garbage collection and is removed from the table when the object is collected
ParametersuseWeakReferences:Boolean (default = true ) — if weak key references should be used
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap( false );
clear | () | method |
public function clear():void
Resets all key / values in the HashMap instance to null
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.size() ); //2 map.clear(); trace( map.size() ); //0
clearAllExcept | () | method |
public function clearAllExcept(keyId:*):void
Clears all key / values defined in the HashMap instance with the exception of the specified key
ParameterskeyId:* — key which is not to be cleared from the map
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.size() ); //2 map.clearAllExcept( "editor", editorVO ); trace( map.getValues() ); //[object, editorVO] trace( map.size() ); //1
containsKey | () | method |
public function containsKey(key:*):Boolean
Determines if a key exists in the HashMap instance
Parameterskey:* — the key in which to determine existance in the map
|
Boolean — true if the key exisits, false if not
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); trace( map.containsKey( "admin" ) ); //true
containsValue | () | method |
public function containsValue(value:*):Boolean
Determines if a value exists in the HashMap instance
Parametersvalue:* — the value in which to determine existance in the map
|
Boolean — true if the value exisits, false if not
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); trace( map.containsValue( adminVO ) ); //true
getEntries | () | method |
public function getEntries():IList
Returns an IList
of IHashMapEntry
objects based on the underlying internal map.
IList |
getKey | () | method |
public function getKey(value:*):*
Returns a key value from the HashMap instance
Parametersvalue:* — the key in which to retrieve the value of
|
String — the value of the specified key
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); trace( map.getKey( adminVO ) ); //admin
getKeys | () | method |
public function getKeys():Array
Returns each key added to the HashMap instance
ReturnsArray — Array of key identifiers
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.getKeys() ); //admin, editor
getValue | () | method |
public function getValue(key:*):*
Retrieves the value of the specified key from the HashMap instance
Parameterskey:* — the key in which to retrieve the value of
|
* — the value of the specified key, otherwise returns undefined
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.getValue( "editor" ) ); //[object, editorVO]
getValues | () | method |
public function getValues():Array
Retrieves each value assigned to each key in the HashMap instance
ReturnsArray — Array of values assigned for all keys in the map
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.getValues() ); //[object, adminVO],[object, editorVO]
isEmpty | () | method |
public function isEmpty():Boolean
Determines if the current HashMap instance is empty
ReturnsBoolean — true if the current map is empty, false if not
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); trace( map.isEmpty() ); //true map.put( "admin", adminVO ); trace( map.isEmpty() ); //false
put | () | method |
public function put(key:*, value:*):void
Adds a key and value to the HashMap instance
Parameterskey:* — key to add to the map
|
|
value:* — value of the specified key
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "user", userVO );
putAll | () | method |
public function putAll(table:Dictionary):void
Places all name / value pairs into the current
IMap
instance.
table:Dictionary — Object of name / value pairs
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var table:Object = {a: "foo", b: "bar"}; var map:IMap = new HashMap(); map.putAll( table ); trace( map.getValues() ); // foo, bar
putEntry | () | method |
public function putEntry(entry:IHashMapEntry):void
putEntry
is intended as a pseudo-overloaded
put
implementation whereby clients may call
putEntry
to pass an IHashMapEntry
implementation.
entry:IHashMapEntry — IHashMapEntry implementation
|
remove | () | method |
public function remove(key:*):void
Removes a key and value from the HashMap instance
Parameterskey:* — key to remove from the map
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.remove( "admin" );
reset | () | method |
public function reset():void
Resets all key value assignments in the HashMap instance to null
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); map.reset(); trace( map.getValues() ); //null, null
resetAllExcept | () | method |
public function resetAllExcept(keyId:*):void
Resets all key / values defined in the HashMap instance to null with the exception of the specified key
ParameterskeyId:* — key which is not to be cleared from the map
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.getValues() ); //[object, adminVO],[object, editorVO] map.resetAllExcept( "editor", editorVO ); trace( map.getValues() ); //null,[object, editorVO]
size | () | method |
public function size():int
Determines the size of the HashMap instance
Returnsint — the current size of the map instance
|
import com.ericfeminella.collections.HashMap; import com.ericfeminella.collections.IMap; var map:IMap = new HashMap(); map.put( "admin", adminVO ); map.put( "editor", editorVO ); trace( map.size() ); //2