HashMap

A hash table using direct lookup (perfect hashing).  Each key can only map one value at a time and multiple keys can map the same value.  The HashMap is preallocated according to an initial size, but afterwards automatically resized if the number of key-value pairs exceeds the predefined size.

Summary
HashMapA hash table using direct lookup (perfect hashing).
Functions
HashMapInitializes a new HashMap instance.
insertInserts a key/data couple into the table.
findFinds the value that is associated with the given key.
removeRemoves a value based on a given key.
containsKeyChecks if a mapping exists for the given key.
getKeySetWrites all keys into an array.
contains@inheritDoc
clear@inheritDoc
getIterator@inheritDoc
Properties
size@inheritDoc
Functions
isEmpty@inheritDoc
toArray@inheritDoc
toStringPrints out a string representing the current object.
dumpPrints out all elements (for debug/demo purposes).

Functions

HashMap

public function HashMap(size: int = 500)

Initializes a new HashMap instance.

Parameters

sizeThe initial capacity of the HashMap. 

insert

public function insert(key: *,
obj: *):Boolean

Inserts a key/data couple into the table.

Parameters

keyThe key.
objThe data associated with the key. 

find

public function find(key: *):*

Finds the value that is associated with the given key.

Parameters

param key The key mapping a value.

Returns

The data associated with the key or null if no matching entry was found. 

remove

public function remove(key: *):*

Removes a value based on a given key.

Parameters

param key The entry’s key.

Returns

The data associated with the key or null if no matching entry was found. 

containsKey

public function containsKey(key: *):Boolean

Checks if a mapping exists for the given key.

Returns

True if key exists, otherwise false. 

getKeySet

public function getKeySet():Array

Writes all keys into an array.

Returns

An array containing all keys. 

contains

public function contains(obj: *):Boolean

@inheritDoc

clear

public function clear():void

@inheritDoc

getIterator

public function getIterator():Iterator

@inheritDoc

Properties

size

public function get size():int

@inheritDoc

Functions

isEmpty

public function isEmpty():Boolean

@inheritDoc

toArray

public function toArray():Array

@inheritDoc

toString

public function toString():String

Prints out a string representing the current object.

Returns

A string representing the current object. 

dump

public function dump():String

Prints out all elements (for debug/demo purposes).

Returns

A human-readable representation of the structure. 

A ‘java-style’ collection interface.
The ‘ICollection’ interface defines a common interface for all collection objects.
The ‘IDisposable’ interface defines a common interface for all objects to encorporate garbage collection.
public function HashMap(size: int = 500)
Initializes a new HashMap instance.
public function insert(key: *,
obj: *):Boolean
Inserts a key/data couple into the table.
public function find(key: *):*
Finds the value that is associated with the given key.
public function remove(key: *):*
Removes a value based on a given key.
public function containsKey(key: *):Boolean
Checks if a mapping exists for the given key.
public function getKeySet():Array
Writes all keys into an array.
public function contains(obj: *):Boolean
@inheritDoc
public function clear():void
@inheritDoc
public function getIterator():Iterator
@inheritDoc
public function get size():int
@inheritDoc
public function isEmpty():Boolean
@inheritDoc
public function toArray():Array
@inheritDoc
public function toString():String
Prints out a string representing the current object.
public function dump():String
Prints out all elements (for debug/demo purposes).
Close