Overview Module Function Class Tea 3.2.4 Reference Documentation
© 2009 PDM&FC

Class THashtable

A THashtable represents a set of unordered objects. Each object in the set is indexed by a key. A key is an object of any type. A THashtable can be thought of as a sequence of key, value pairs.

Method Summary
addElements elementData
         Adds multiple elements to this table.
clear
         Removes all the elements from the THashtable.
constructor
         Initializes an empty hashtable.
get key
         Fetches an object stored in the THashtable.
getElements
         Fetches a list of the objects stored in the THashtable.
getKeys
         Fetches a list of the keys of the objects stored in the THashtable.
isKey object
         Checks if an object is being used as key for one of the elements in the THashtable.
put key value
         Adds an object to the THashtable.
remove [key ...]
         Removes one or more elements from the THashtable.

Method Detail

addElements

THashtable addElements elementData

Adds multiple elements to this table.

Parameters:
elementData - A list containing the elements to add.
Returns:
A reference to the THashtable object for which the method was called.

The elementData argument defines the objects to add to this table. Each element in the elementData is a two element list. The first is used as the key and the second is used as the value.

This method could be implemented in the following way:

method THashtable addElements ( elemList ) {
   foreach elemData $elemList {
       apply $this put $elemData
   }
   is $this
}


clear

THashtable clear

Removes all the elements from the THashtable.

Returns:
A reference to the THashtable object for which the method was called.


constructor

THashtable constructor

Initializes an empty hashtable.


get

THashtable get key

Fetches an object stored in the THashtable.

Parameters:
key - An object of any type. It will be used as the index into the object to fetch.
Returns:
A reference to the object indexed by key. The null object if there is no object associated with key stored in the THashtable. You can check if there is an element indexed by key my calling the THashtable isKey method.


getElements

THashtable getElements

Fetches a list of the objects stored in the THashtable.

Returns:
A list containing all the objects stored in the THashtable.

There is no guarantee on the order of the elements in the list that is returned.

getKeys

THashtable getKeys

Fetches a list of the keys of the objects stored in the THashtable.

Returns:
A list containing all the keys for the objects stored in the THashtable.

There is no guarantee on the order of the elements in the list that is returned.

isKey

THashtable isKey object

Checks if an object is being used as key for one of the elements in the THashtable.

Returns:
True if object is being used as key for one of the elements in the THashtable. False otherwise.


put

THashtable put key value

Adds an object to the THashtable.

Parameters:
key - An object of any type. It will be used as the index to value.
value - The object being added to the THashtable.
Returns:
A reference to the THashtable object for which the method was called.

If an object with the same key already exists in the THashtable then value will take its place.

remove

THashtable remove [key ...]

Removes one or more elements from the THashtable.

Parameters:
key - The key of the element to remove. It may be an object of any type.
Returns:
A reference to the THashtable object for which the method was called.

Removes the elements in this THashtable associated with each of the keys given as arguments.

If there is no object indexed by key in the THashtable then it has no effect.



Overview Module Function Class Tea 3.2.4 Reference Documentation
© 2009 PDM&FC
Report a bug or request new features
© 2009