| Package | com.elad.framework.utils.collections |
| Class | public class HashMapCollection |
| Implements | IMap |
IMap interface.
HashMapCollection class makes no guarantees to the order of the map or that the order
will remain the same. The class let you pass a pair of keys and values and
provides constant-time performance for the basic operations of
addItem, removeItemAt and getItemValue
since they require no iteration over the collection.
Example shows how to use the HashMapCollection
private function map():void {
var map:IMap = new HashMapCollection();
map.addEventListener(CollectionEvent.COLLECTION_CHANGE, handler);
map.addItem("John", "212-452-8086");
map.addItem("James", "718-345-3455");
map.addItem("Micheal", "917-782-8822");
map.addItem("Ron", "212-426-8855");
map.addItem("Mike", "212-255-2436");
map.addItem("Jenny", "718-344-2433");
map.addItem("Jack", "917-222-4352");
map.addItem("Riki", "981-222-1122");
trace("\nAll items: "+map.toString()+"\n");
trace("containsKey Jack? "+map.containsKey("Jack"));
trace("containsValue 718-344-2433? "+map.containsValue("718-344-2433"));
trace("getItemKey 718-344-2433: "+map.getItemKey("718-344-2433"));
trace("getItemValue Jenny: "+map.getItemValue("Jenny"));
map.removeItemAt("Riki");
trace("Remove Riki.");
trace("getItemValue Riki: "+map.getItemValue("Riki"));
trace("Comapre: "+map.compare("Ron", "212-426-8855"));
map.removeAll();
trace("\nAll items: "+map.toString()+"\n");
}
private function handler(event:CollectionEvent):void
{
trace("Event: "+event.kind);
}
See also
| Property | Defined by | ||
|---|---|---|---|
| addAll : HashMapCollection
[write-only]
Copies all of the mappings from the specified map to this map
These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
| HashMapCollection | ||
| isEmpty : Boolean [read-only]
Check if the collection has pairs of values and keys or empty
| HashMapCollection | ||
| keySet : Array [read-only]
Returns an array collection of the keys contained in this map.
| HashMapCollection | ||
| length : int [read-only]
Will result in the length of the map collection.
| HashMapCollection | ||
| Method | Defined by | ||
|---|---|---|---|
|
HashMapCollection(useWeakReferences:Boolean = true)
Defualt constractor create the
Dictionary and set the event dispatcher. | HashMapCollection | ||
|
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
| HashMapCollection | ||
|
addItem(key:*, value:*):void
Add a pair consists of key and value.
| HashMapCollection | ||
|
clone():Object
Clone the map, the keys and values themselves are not cloned.
| HashMapCollection | ||
|
compare(key:*, value:*):Boolean
Compare specified key with the map value for equality.
| HashMapCollection | ||
|
containsKey(key:*):Boolean
Method to check if a key exists in the map collection.
| HashMapCollection | ||
|
containsValue(value:*):Boolean
Method to check if a value exist in the map colletcion.
| HashMapCollection | ||
|
dispatchEvent(event:Event):Boolean
| HashMapCollection | ||
|
getItemKey(value:*):String
Retrieve an item key based on a value.
| HashMapCollection | ||
|
getItemsValues():Array
Method to retrieve all the items values in the collection.
| HashMapCollection | ||
|
getItemValue(key:*):*
Retrieve item value based on the item key.
| HashMapCollection | ||
|
getKeys():Array
Method to retrieve the list of keys avaliable in the map.
| HashMapCollection | ||
|
hasEventListener(type:String):Boolean
| HashMapCollection | ||
|
removeAll():void
Remove the entire pairs in the collection.
| HashMapCollection | ||
|
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
| HashMapCollection | ||
|
removeItemAt(key:*):void
Remove the value based on the key without the need to iteration.
| HashMapCollection | ||
|
reset():void
Method to clear the values of the collection.
| HashMapCollection | ||
|
toString():String
Method to convert the map into a string representation consists of a list of key-value.
| HashMapCollection | ||
|
willTrigger(type:String):Boolean
| HashMapCollection | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
Dispatched when the HashMapCollection has been updated in some way. | HashMapCollection | |||
| addAll | property |
addAll:HashMapCollection [write-only]Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
Implementation public function set addAll(value:HashMapCollection):void
| isEmpty | property |
isEmpty:Boolean [read-only]Check if the collection has pairs of values and keys or empty
Implementation public function get isEmpty():Boolean
| keySet | property |
keySet:Array [read-only]Returns an array collection of the keys contained in this map.
Implementation public function get keySet():Array
| length | property |
length:int [read-only]Will result in the length of the map collection.
Implementation public function get length():int
| HashMapCollection | () | constructor |
public function HashMapCollection(useWeakReferences:Boolean = true)
Defualt constractor create the Dictionary and set the event dispatcher.
useWeakReferences:Boolean (default = true) — Instructs the Dictionary object to use "weak" references on object keys.
|
See also
| addEventListener | () | method |
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):voidParameters
type:String |
|
listener:Function |
|
useCapture:Boolean (default = false) |
|
priority:int (default = 0) |
|
useWeakReference:Boolean (default = false) |
| addItem | () | method |
public function addItem(key:*, value:*):voidAdd a pair consists of key and value.
Parameterskey:* |
|
value:* |
| clone | () | method |
public function clone():ObjectClone the map, the keys and values themselves are not cloned.
ReturnsObject — Returns a shallow copy of this HashMap instance
|
| compare | () | method |
public function compare(key:*, value:*):BooleanCompare specified key with the map value for equality.
Parameterskey:* |
|
value:* |
Boolean |
| containsKey | () | method |
public function containsKey(key:*):BooleanMethod to check if a key exists in the map collection.
Parameterskey:* |
Boolean |
| containsValue | () | method |
public function containsValue(value:*):BooleanMethod to check if a value exist in the map colletcion.
Parametersvalue:* |
Boolean |
| dispatchEvent | () | method |
public function dispatchEvent(event:Event):BooleanParameters
event:Event |
Boolean |
| getItemKey | () | method |
public function getItemKey(value:*):StringRetrieve an item key based on a value.
Parametersvalue:* |
String |
| getItemsValues | () | method |
public function getItemsValues():ArrayMethod to retrieve all the items values in the collection.
ReturnsArray — An array collection with all the values.
|
| getItemValue | () | method |
public function getItemValue(key:*):*Retrieve item value based on the item key.
Parameterskey:* |
* |
| getKeys | () | method |
public function getKeys():ArrayMethod to retrieve the list of keys avaliable in the map.
ReturnsArray — An array collection with the keys.
|
| hasEventListener | () | method |
public function hasEventListener(type:String):BooleanParameters
type:String |
Boolean |
| removeAll | () | method |
public function removeAll():voidRemove the entire pairs in the collection.
| removeEventListener | () | method |
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):voidParameters
type:String |
|
listener:Function |
|
useCapture:Boolean (default = false) |
| removeItemAt | () | method |
public function removeItemAt(key:*):voidRemove the value based on the key without the need to iteration. The method also call an event dispatcher.
Parameterskey:* |
| reset | () | method |
public function reset():voidMethod to clear the values of the collection. Keys will stays but values will be removed.
| toString | () | method |
public function toString():StringMethod to convert the map into a string representation consists of a list of key-value.
ReturnsString — Returns a string representation of this map. The string representation consists of a list of key-value.
|
| willTrigger | () | method |
public function willTrigger(type:String):BooleanParameters
type:String |
Boolean |
| collectionChange | event |
mx.events.CollectionEvent
Dispatched when the HashMapCollection has been updated in some way.