| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
The
HashCodeFactory class provides convenient methods
to emulate the behavior of the Java™
Object.hashcode()
method. The hashcode factory provides an unique identifier for any
instance in an application.
However, there is a major difference between the Java™ behavior
and the Flash™ behavior. In Java™ the hashcode method
will return the same value for two different instance of the same
class which have the same properties value, in Flash™ the
hashcode factory will return a different identifier for all instances
even if their properties are equals.
public static function getKey(o:*):String
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
Returns the hashcode key associated to the passed-in object.
If the objects has not yet a hashcode, the function will generate
one and then register the object with its hashcode.
Parameters
| o:* — object for which get the hashcode key
|
Returns
| String — the string hashcode for the passed-in object
|
public static function getNextKey():String
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
Returns the next unique identifier, two consecutives
call to the getNextKey will generate two
different keys. To get the next key without changing
the next call result use the previewNextKey
method.
Returns
| String — the next unique identifier
|
See also
public static function hasKey(o:*):Boolean
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
Returns true if the passed-in object already
have a hashcode key.
Parameters
| o:* — object for which verify the presence of a hashcode key
|
Returns
| Boolean — true if the passed-in object already
have a hashcode key
|
public static function previewNextKey():String
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
Returns the next key the getNextKey
will return, without causing the getNextKey
method returning a different key. Calling several times
the previewNextKey method will never affect
the next call of the getNextKey method.
Returns
| String — a preview of the next unique identifier
|
protected static const _oHashTable:Dictionary
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
A hash map which store the generated keys for each object for which
an identifier was generated. Objects are stored as weak reference
so they will be collected as any other object which has no hashcode
identifier.
LowRA API documentation 2008- 2009
Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1
mer. févr. 25 2009, 9:22 AM GMT+01:00