| Package | de.polygonal.ds |
| Class | public class HashTable |
| Inheritance | HashTable Object |
| Implements | Collection |
| Subclasses | ZobristHashTable |
See also
| Property | Defined By | ||
|---|---|---|---|
| maxSize : int [read-only]
The hash table's maximum capacity. | HashTable | ||
| size : int [read-only]
The total number of items. | HashTable | ||
| 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 | ||
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 | ||
| _size | property |
protected var _size:int| _table | property |
protected var _table:Array| maxSize | property |
maxSize:int [read-only] The hash table's maximum capacity.
public function get maxSize():int| size | property |
size:int [read-only] The total number of items.
public function get size():int| HashTable | () | Constructor |
public function HashTable(size:int, hash:Function = null)Initializes a new hash table.
Parameterssize:int — The size of the hash table.
| |
hash:Function (default = null) — A hashing function.
|
| clear | () | method |
public function clear():voidClears all items.
| contains | () | method |
public function contains(obj:*):BooleanDetermines if the collection contains a given item.
Parameters
obj:* — The item to search for.
|
Boolean — True if the item exists, otherwise false.
|
| dump | () | method |
public function dump():StringPrints out all elements (for debug/demo purposes).
ReturnsString — 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.
|
* — The data associated with the key or null if no matching
entry was found.
|
| getIterator | () | method |
public function getIterator():IteratorInitializes an iterator object pointing to the first item in the collection.
ReturnsIterator — An iterator object.
|
| hashInt | () | method |
public static function hashInt(i:int):intA simple function for hashing integers.
Parameters
i:int |
int |
| hashString | () | method |
public static function hashString(s:String):intA simple function for hashing strings.
Parameters
s:String |
int |
| insert | () | method |
public function insert(key:*, obj:*):voidInserts a key/data couple into the table.
Parameters
key:* — The key.
| |
obj:* — The data associated with the key.
|
| isEmpty | () | method |
public function isEmpty():BooleanChecks if the collection is empty.
ReturnsBoolean — 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.
|
* — The data associated with the key or null if no matching
entry was found.
|
| toArray | () | method |
public function toArray():ArrayConverts the collection into an array.
ReturnsArray — An array.
|
| toString | () | method |
public function toString():StringPrints out a string representing the current object.
ReturnsString — A string representing the current object.
|