Packagecom.developmentarc.framework.datastructures.utils
Classpublic class HashTable

The hash table is similar to a Dictionary in that a key object is used to map data. Unlike a Dictionary the HashTable behaves similar to an Array providing the ability check length and get itmes by position.



Public Properties
 PropertyDefined by
  isEmpty : Boolean
[read-only] Used to determine if there are currently item pairs in the table.
HashTable
  length : int
[read-only] Returns the number of items currently inside the HashTable.
HashTable
Public Methods
 MethodDefined by
  
Constructor for the HashTable.
HashTable
  
addItem(key:*, item:*):void
Adds a key/item pair to the HashTable.
HashTable
  
containsItem(item:*):Boolean
Looks up the requested item and returns true if the item is contained, false if it is not.
HashTable
  
containsKey(key:*):Boolean
Looks up the requested key and returns true if the key is contained, false if it is not.
HashTable
  
getAllItems():Array
Returns all items stored in the HashTable.
HashTable
  
getAllKeys():Array
Returns all keys stored in the HashTable.
HashTable
  
getItem(key:*):*
Returns the item for the specified key, if the key is not found then the method returns null.
HashTable
  
getKeyAt(position:int):*
Returns the key at a specified position if the HashTable has that position available.
HashTable
  
remove(key:*):void
Removes an item/key pair based on the key provided.
HashTable
  
removeAll():void
Removes all items and keys from the HashTable.
HashTable
Property detail
isEmptyproperty
isEmpty:Boolean  [read-only]

Used to determine if there are currently item pairs in the table.

Implementation
    public function get isEmpty():Boolean
lengthproperty 
length:int  [read-only]

Returns the number of items currently inside the HashTable.

Implementation
    public function get length():int
Constructor detail
HashTable()constructor
public function HashTable()

Constructor for the HashTable.

Method detail
addItem()method
public function addItem(key:*, item:*):void

Adds a key/item pair to the HashTable. This enables the ability to lookup items by key or position. This also enables keys to be found by items or position.

Parameters
key:*
 
item:*
containsItem()method 
public function containsItem(item:*):Boolean

Looks up the requested item and returns true if the item is contained, false if it is not.

Parameters
item:* — Item to lookup.

Returns
Boolean — True if found, false if not.
containsKey()method 
public function containsKey(key:*):Boolean

Looks up the requested key and returns true if the key is contained, false if it is not.

Parameters
key:* — Key to lookup.

Returns
Boolean — True if found, false if not.
getAllItems()method 
public function getAllItems():Array

Returns all items stored in the HashTable. The returned Array is a clone of the stored array to prevent key pair corruption.

Returns
Array — Array of all the contained items.
getAllKeys()method 
public function getAllKeys():Array

Returns all keys stored in the HashTable. The returned Array is a clone of the stored array to prevent key pair corruption.

Returns
Array — Array of all the contained keys.
getItem()method 
public function getItem(key:*):*

Returns the item for the specified key, if the key is not found then the method returns null.

Parameters
key:* — Key object to look up item.

Returns
* — Item bound to key.
getKeyAt()method 
public function getKeyAt(position:int):*

Returns the key at a specified position if the HashTable has that position available.

Parameters
position:int — Position to return key.

Returns
* — Key at specified position.
remove()method 
public function remove(key:*):void

Removes an item/key pair based on the key provided.

Parameters
key:* — Key to remove item on.
removeAll()method 
public function removeAll():void

Removes all items and keys from the HashTable.