Class Index | File Index

Classes


Class HashTable


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
HashTable(size)
Class for managing an hash table.
Field Summary
Field Attributes Field Name and Description
 
The items stored in the hash table.
 
The number of keys stored in the hash table.
 
The size of the table
Method Summary
Method Attributes Method Name and Description
 
Removes all the keys and the items stored in the hash table.
 
Clones the hash table into a new hash table.
 
containsKey(key, callback)
Checks if the hash table contains a key that satisfy the condition represented by the callback function.
 
Deletes all the items relative to the key value.
 
deleteKey(key)
Deletes the first item relatives to the key value.
 
execute(callback)
Executes the callback function for each item of the hash table.
 
filter(callback)
Returns the items that satisfy the condition determined by the callback.
 
Returns the items stored in the hash table.
 
Returns the keys stored in the hash table.
 
Returns the number of keys stored in the hash table.
 
Returns the size of the hash table.
 
hash(key)
Calculate the hash of the param key.
 
insert(key, item)
Stores the item with its key.
 
Checks if the hash table is empty.
 
search(key)
Searches the item relative to the key value.
 
searchAll(key)
Searches all the items relative to the key value.
Class Detail
HashTable(size)
Class for managing an hash table.
Parameters:
size
{number} The size of the table.
Field Detail
items
The items stored in the hash table.

keyLength
The number of keys stored in the hash table.

size
The size of the table
Method Detail
{void} clear()
Removes all the keys and the items stored in the hash table.
Returns:
{void}

{HashTable} clone()
Clones the hash table into a new hash table.
Returns:
{HashTable} The hash table cloned from this hash table.

{boolean} containsKey(key, callback)
Checks if the hash table contains a key that satisfy the condition represented by the callback function.
Parameters:
key
{number} The key to find.
callback Optional, Default: function(k){return(k===key);}
The condition to satisfy. The callback must accept the current key to check.
Returns:
{boolean} True if the hash table contains the key that satisfy the condition, false otherwise.

{void} deleteAllKey(key)
Deletes all the items relative to the key value.
Parameters:
key
{number} The key to delete.
Returns:
{void}

{void} deleteKey(key)
Deletes the first item relatives to the key value.
Parameters:
key
{number} The key to delete.
Returns:
{void}

{void} execute(callback)
Executes the callback function for each item of the hash table. This method modifies the hash table so if you don't need to modify it you must return the same item stored.
Parameters:
callback
{function} The function to execute for each item. The function must accept the current item on which execute the function.
Returns:
{void}

{Array<*>} filter(callback)
Returns the items that satisfy the condition determined by the callback.
Parameters:
callback
{function} The function that implements the condition.
Returns:
{Array<*>} The array that contains the items that satisfy the condition.

{Array<*>} getItems()
Returns the items stored in the hash table.
Returns:
{Array<*>} The items stored in the table.

{Array} getKeys()
Returns the keys stored in the hash table.
Returns:
{Array} The keys stored in the table.

{number} getNumberOfKeys()
Returns the number of keys stored in the hash table.
Returns:
{number} The number of keys stored.

{number} getSize()
Returns the size of the hash table.
Returns:
{number} The size of the hash table.

{number} hash(key)
Calculate the hash of the param key.
Parameters:
key
{number} The key to hash.
Returns:
{number} The hash of the key.

insert(key, item)
Stores the item with its key.
Parameters:
key
{number} The key relatives to the item.
item
{*} The item to store.

{boolean} isEmpty()
Checks if the hash table is empty.
Returns:
{boolean} True if the hash table is empty, false otherwise.

{*|undefined} search(key)
Searches the item relative to the key value.
Parameters:
key
{number} The key of the item to search.
Returns:
{*|undefined} The item found or undefined if the key does not exist.

{Array.<*>} searchAll(key)
Searches all the items relative to the key value.
Parameters:
key
{number} The key of the items to search.
Returns:
{Array.<*>} An array with the items found.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 23 2014 22:40:58 GMT+0200 (CEST)