abstract Dictionary<K, V>(IMap<K, V>)
package openfl.utils
The Dictionary class lets you create a dynamic collection of properties,
which uses strict equality (===
) for key comparison. When an object is
used as a key, the object's identity is used to look up the object, and
not the value returned from calling toString()
on it.
The following statements show the relationship between a Dictionary object
and a key object:
var dict = new Dictionary();
var obj = new Object();
var key:Object = new Object();
key.toString = function() { return "key" }
dict[key] = "Letters";
obj["key"] = "Letters";
dict[key] == "Letters"; // true
obj["key"] == "Letters"; // true
obj[key] == "Letters"; // true because key == "key" is true b/c key.toString == "key"
dict["key"] == "Letters"; // false because "key" === key is false
delete dict[key]; //removes the key
Static methods
staticinlineeach(this:IMap<K, V>):Iterator<V>
Returns an Iterator over each of the values of this Dictionary.
The order of values is undefined.
staticinlineget(this:IMap<K, V>, key:K):V
Returns the current mapping of key
.
If no such mapping exists, null
is returned.
Note that a check like dict.get(key) == null
can hold for two reasons:
- The Dictionary has no mapping for
key
- The Dictionary has a mapping with a value of
null
If it is important to distinguish these cases, exists()
should be used.
If key
is null, the result is unspecified.
staticinlineiterator(this:IMap<K, V>):Iterator<K>
Returns an Iterator over the keys of this Dictionary.
The order of values is undefined.
staticinlinekeyValueIterator(this:IMap<K, V>):KeyValueIterator<K, V>
Returns an Iterator over the keys and values of this Dictionary.
The order of values is undefined.