| Package | org.aswing.util |
| Class | public class HashMap |
| Subclasses | UIDefaults |
---------------------------------------------------------- This example creates a HashMap of friends. It uses the number of the friends as keys:
function person(name,age,sex){
this.name=name;
this.age=age;
this.sex=sex;
}
var friends = new HashMap();
friends.put("one", new person("iiley",21,"M"));
friends.put("two", new person("gothic man",22,"M"));
friends.put("three", new person("rock girl",19,"F"));
To retrieve a friends, use the following code:
var thisperson = friends.get("two");
if (thisperson != null) {
trace("two name is "+thisperson.name);
trace("two age is "+thisperson.age);
trace("two sex is "+thisperson.sex);
}else{
trace("two is not in friends!");
}
| Method | Defined by | ||
|---|---|---|---|
|
HashMap()
| HashMap | ||
|
clear():void
Clears this HashMap so that it contains no keys no values.
| HashMap | ||
|
Return a same copy of HashMap object
| HashMap | ||
|
containsKey(key:*):Boolean
Tests if the specified object is a key in this HashMap.
| HashMap | ||
|
containsValue(value:*):Boolean
Tests if some key maps into the specified value in this HashMap.
| HashMap | ||
|
eachKey(func:Function):void
Call func(key) for each key.
| HashMap | ||
|
eachValue(func:Function):void
Call func(value) for each value.
| HashMap | ||
|
get(key:*):*
Returns the value to which the specified key is mapped in this HashMap.
| HashMap | ||
|
getValue(key:*):*
Same functionity method with different name to
get. | HashMap | ||
|
isEmpty():Boolean
Returns if this HashMap maps no keys to values.
| HashMap | ||
|
keys():Array
Returns an Array of the keys in this HashMap.
| HashMap | ||
|
put(key:*, value:*):*
Associates the specified value with the specified key in this map.
| HashMap | ||
|
remove(key:*):*
Removes the mapping for this key from this map if present.
| HashMap | ||
|
size():int
Returns the number of keys in this HashMap.
| HashMap | ||
|
toString():String
| HashMap | ||
|
values():Array
Returns an Array of the values in this HashMap.
| HashMap | ||
| HashMap | () | constructor |
public function HashMap()
| clear | () | method |
public function clear():voidClears this HashMap so that it contains no keys no values.
| clone | () | method |
| containsKey | () | method |
public function containsKey(key:*):BooleanTests if the specified object is a key in this HashMap. This operation is very fast if it is a string.
Parameterskey:* — key The key whose presence in this map is to be tested
|
Boolean — true if this map contains a mapping for the specified
|
| containsValue | () | method |
public function containsValue(value:*):BooleanTests if some key maps into the specified value in this HashMap. This operation is more expensive than the containsKey method.
Parametersvalue:* |
Boolean |
| eachKey | () | method |
public function eachKey(func:Function):voidCall func(key) for each key.
Parametersfunc:Function — the function to call
|
| eachValue | () | method |
public function eachValue(func:Function):voidCall func(value) for each value.
Parametersfunc:Function — the function to call
|
| get | () | method |
public function get(key:*):*Returns the value to which the specified key is mapped in this HashMap. Return null if the key is not mapped to any value in this HashMap. This operation is very fast if the key is a string.
Parameterskey:* — key the key whose associated value is to be returned.
|
* — the value to which this map maps the specified key, or
null if the map contains no mapping for this key
or it is null value originally.
|
| getValue | () | method |
public function getValue(key:*):*
Same functionity method with different name to get.
key:* — key the key whose associated value is to be returned.
|
* — the value to which this map maps the specified key, or
null if the map contains no mapping for this key
or it is null value originally.
|
| isEmpty | () | method |
public function isEmpty():BooleanReturns if this HashMap maps no keys to values.
ReturnsBoolean |
| keys | () | method |
public function keys():ArrayReturns an Array of the keys in this HashMap.
ReturnsArray |
| put | () | method |
public function put(key:*, value:*):*Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced. If value is null, means remove the key from the map.
Parameterskey:* — key with which the specified value is to be associated.
|
|
value:* — value to be associated with the specified key. null to remove the key.
|
* — previous value associated with specified key, or null
if there was no mapping for key. A null return can
also indicate that the HashMap previously associated
null with the specified key.
|
| remove | () | method |
public function remove(key:*):*Removes the mapping for this key from this map if present.
Parameterskey:* — key key whose mapping is to be removed from the map.
|
* — 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():intReturns the number of keys in this HashMap.
Returnsint |
| toString | () | method |
public function toString():String
Returns
String |
| values | () | method |
public function values():ArrayReturns an Array of the values in this HashMap.
ReturnsArray |