GODPAPER | All Packages | All Classes | Index | Frames No Frames |
HashTable

Package | de.polygonal.ds
Class | public class HashTable
Inheritance | HashTable Object
Implements | Collection
Subclasses | ZobristHashTable

A hash table using linked overflow for collision resolving. Depricated, use the HashMap class instead.

See also

HashMap

Public Properties

| Property | Defined By
--- | --- | ---
|  | maxSize : int [read-only] The hash table's maximum capacity. | HashTable
|  | size : int [read-only] The total number of items. | HashTable

Protected Properties

| Property | Defined By
--- | --- | ---
|  | _size : int | HashTable
|  | _table : Array | HashTable

Public Methods

| Method | Defined By
--- | --- | ---
|  | HashTable(size:int, hash:Function = null) Initializes a new hash table. | HashTable
|  | clear():void Clears all items. | HashTable
|  | contains(obj:*):Boolean Determines if the collection contains a given item. | HashTable
|  | dump():String Prints out all elements (for debug/demo purposes). | HashTable
|  | find(key:*):* Finds the entry that is associated with the given key. | HashTable
|  | getIterator():Iterator Initializes an iterator object pointing to the first item in the collection. | HashTable
|  | hashInt(i:int):int [static] A simple function for hashing integers. | HashTable
|  | hashString(s:String):int [static] A simple function for hashing strings. | HashTable
|  | insert(key:*, obj:*):void Inserts a key/data couple into the table. | HashTable
|  | isEmpty():Boolean Checks if the collection is empty. | HashTable
|  | remove(key:*):* Removes an entry based on a given key. | HashTable
|  | toArray():Array Converts the collection into an array. | HashTable
|  | toString():String Prints out a string representing the current object. | HashTable

Property Detail

_size | property

`protected var _size:int`

_table | property |

`protected var _table:Array`

maxSize | property |

`maxSize:int` [read-only]

The hash table's maximum capacity.

Implementation
`public function get maxSize():int`

size | property |

`size:int` [read-only]

The total number of items.

Implementation
`public function get size():int`
Constructor Detail

HashTable | () | Constructor

`public function HashTable(size:int, hash:Function = null)`

Initializes a new hash table.

Parameters

| `size:int` — The size of the hash table.
| `hash:Function` (default = `null`)`` — A hashing function.

Method Detail

clear | () | method

`public function clear():void`

Clears all items.

contains | () | method |

`public function contains(obj:*):Boolean`

Determines if the collection contains a given item.

Parameters

| `obj:*` — The item to search for.

Returns

| `Boolean` — True if the item exists, otherwise false.

dump | () | method |

`public function dump():String`

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

Returns

| `String` — A human-readable representation of the structure.

find | () | method |

`public function find(key:*):*`

Finds the entry that is associated with the given key.

Parameters

| `key:*` — The key to search for.

Returns

| `*` — The data associated with the key or null if no matching entry was found.

getIterator | () | method |

`public function getIterator():Iterator`

Initializes an iterator object pointing to the first item in the collection.

Returns

| `Iterator` — An iterator object.

hashInt | () | method |

`public static function hashInt(i:int):int`

A simple function for hashing integers.

Parameters

| `i:int`

Returns

| `int`

hashString | () | method |

`public static function hashString(s:String):int`

A simple function for hashing strings.

Parameters

| `s:String`

Returns

| `int`

insert | () | method |

`public function insert(key:*, obj:*):void`

Inserts a key/data couple into the table.

Parameters

| `key:*` — The key.
| `obj:*` — The data associated with the key.

isEmpty | () | method |

`public function isEmpty():Boolean`

Checks if the collection is empty.

Returns

| `Boolean` — True if empty, otherwise false.

remove | () | method |

`public function remove(key:*):*`

Removes an entry based on a given key.

Parameters

| `key:*` — The entry's key.

Returns

| `*` — The data associated with the key or null if no matching entry was found.

toArray | () | method |

`public function toArray():Array`

Converts the collection into an array.

Returns

| `Array` — An array.

toString | () | method |

`public function toString():String`

Prints out a string representing the current object.

Returns

| `String` — A string representing the current object.

Thu Jan 16 2014, 01:11 PM +08:00