Packagecom.bourre.collection
Classpublic class HashMap

Player version: Flash Player 9.0
Language version: ActionScript 3.0

An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

The "destructive" methods contained in this interface, that is, the methods that modify the map on which they operate, are specified to throw UnsupportedOperationException if this map does not support the operation. If this is the case, these methods may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the map. For example, invoking the putAll(Map) method on an unmodifiable map may, but is not required to, throw the exception if the map whose mappings are to be "superimposed" is empty.

Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible key or value may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. More generally, attempting an operation on an ineligible key or value whose completion would not result in the insertion of an ineligible element into the map may throw an exception or it may succeed, at the option of the implementation. Such exceptions are marked as "optional" in the specification for this interface.

Many methods in Collections Framework interfaces are defined in terms of the === operator. For example, the specification for the containsKey( key : Object ) method says: "returns true if and only if this map contains a mapping for a key k such that key === k." This specification should not be construed to imply that invoking HashMap.containsKey with a non-null argument key will cause key === k to be invoked for any key k. Implementations are free to implement optimizations whereby the === invocation is avoided, for example, by first comparing the hash codes of the two keys. (The HashCodeFactory.getKey(Object) specification guarantees that two objects with unequal hash codes cannot be equal.) More generally, implementations of the various Collections Framework interfaces are free to take advantage of the specified behavior of underlying Object methods wherever the implementor deems it appropriate.



Protected Properties
 PropertyDefined by
  _n : uint
Number of mappings currently in this map
HashMap
  _oKeyDico : Dictionary
A dictionnary which stores the mapping (key - value) for this map.
HashMap
  _oValueDico : Dictionary
A dictionnary which store the mapping (value - occurrences count) for this map.
HashMap
Public Methods
 MethodDefined by
  
Creates a new empty hash map object.
HashMap
  
clear():void
Removes all of the mappings from this map (optional operation).
HashMap
  
containsKey(key:*):Boolean
Returns true if this map contains a mapping for the specified key.
HashMap
  
containsValue(value:*):Boolean
Returns true if this map maps one or more keys to the specified value.
HashMap
  
get(key:*):*
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
HashMap
  
getKeys():Array
Returns an Array view of the keys contained in this map.
HashMap
  
getValues():Array
Returns an Array view of the values contained in this map.
HashMap
  
isEmpty():Boolean
Returns true if this map contains no key-value mappings.
HashMap
  
put(key:*, value:*):*
Associates the specified value with the specified key in this map (optional operation).
HashMap
  
remove(key:*):*
Removes the mapping for a key from this map if it is present (optional operation).
HashMap
  
size():Number
Returns the number of key-value mappings in this map.
HashMap
  
toString():String
Returns the string representation of this instance.
HashMap
Protected Methods
 MethodDefined by
  
_init():void
Realize the concret initialization for this map
HashMap
Property detail
_nproperty
protected var _n:uint

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Number of mappings currently in this map

_oKeyDicoproperty 
protected var _oKeyDico:Dictionary

Player version: Flash Player 9.0
Language version: ActionScript 3.0

A dictionnary which stores the mapping (key - value) for this map.

_oValueDicoproperty 
protected var _oValueDico:Dictionary

Player version: Flash Player 9.0
Language version: ActionScript 3.0

A dictionnary which store the mapping (value - occurrences count) for this map.

Constructor detail
HashMap()constructor
public function HashMap()

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates a new empty hash map object.

Method detail
_init()method
protected function _init():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Realize the concret initialization for this map

clear()method 
public function clear():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

containsKey()method 
public function containsKey(key:*):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that key === k. (There can be at most one such mapping.)

Parameters
key:* — key object whose presence in this map is to be tested

Returns
Booleantrue if this map contains a mapping for the specified key

Throws
NullPointerException — if the specified key is null
containsValue()method 
public function containsValue(value:*):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value === v).

Parameters
value:* — value whose presence in this map is to be tested

Returns
Booleantrue if this map maps one or more keys to the specified value
get()method 
public function get(key:*):*

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that (key === k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

As this map permits null values, a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:* — the key whose associated value is to be returned

Returns
* — the value to which the specified key is mapped, or null if this map contains no mapping for the key

Throws
NullPointerException — if the specified key is null
getKeys()method 
public function getKeys():Array

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns an Array view of the keys contained in this map.

Returns
Array — an array view of the keys contained in this map
getValues()method 
public function getValues():Array

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns an Array view of the values contained in this map.

Returns
Array — an array view of the values contained in this map
isEmpty()method 
public function isEmpty():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this map contains no key-value mappings.

Returns
Booleantrue if this map contains no key-value mappings
put()method 
public function put(key:*, value:*):*

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
key:* — key with which the specified value is to be associated
 
value:* — value to be associated with the specified key

Returns
* — the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Throws
NullPointerException — if the specified key or value is null
remove()method 
public function remove(key:*):*

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that (key === k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

As this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
key:* — key whose mapping is to be removed from the map

Returns
* — the previous value associated with key, or null if there was no mapping for key.

Throws
NullPointerException — if the specified key is null
size()method 
public function size():Number

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the number of key-value mappings in this map.

Returns
Number — the number of key-value mappings in this map
toString()method 
public function toString():String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the string representation of this instance.

Returns
String — the string representation of this instance