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

Class TVector

A TVector represents an ordered set of objects. Each object in the set is indexed by an integer value. The indexes range from zero (the first element) to the number of elements minus one.

Method Summary
append anObject ...
         Inserts one or more elements at the end of the TVector.
clear
         Removes all the elements from the TVector.
constructor [theSize]
         Initializes a TVector with a given number of arguments.
getAt index
         Fetches one element of the TVector at a given position.
getElements
         Fetches a list containing the TVector elements.
getSize
         Fetches the number of elements in the TVector.
init [obj1 ...]
         Initializes the TVector object with a given set of elements.
pop
         Retrieves and removes the last element of the TVector.
push anObject
         Inserts a new element at the end of the TVector.
resize newSize
         Changes the size of the TVector.
setAt anObject index
         Changes one element of the TVector at a given position.
sort aFunction
         Sorts the elements of the TVector acording to a comparison function.

Method Detail

append

TVector append anObject ...

Inserts one or more elements at the end of the TVector.

Parameters:
anObject - The object that will be inserted at the end of the vector.
Returns:
A reference to the object for which the method was called.

Inserts new elements into the TVector. Each one of the arguments passed to the method is inserted at the end of the TVector. The number of elements in the TVector is increased acordingly.

clear

TVector clear

Removes all the elements from the TVector.

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


constructor

TVector constructor [theSize]

Initializes a TVector with a given number of arguments.

Parameters:
theSize - Integer representing the initial size of the vector.

Initializes the vector with theSize elements. All elements are set to the null object. If theSize is not specified then it is taken to be zero.

getAt

TVector getAt index

Fetches one element of the TVector at a given position.

Parameters:
index - An integer representing the index of the element to retrieve.
Returns:
A reference to the object at the index position.

If index is negative or equal to or larger than the size of the TVector then a runtime error ocurrs.

getElements

TVector getElements

Fetches a list containing the TVector elements.

Returns:
A list containing the TVector elements.

The order of the elements in the list that is returned is the same order of the elements in the TVector.

getSize

TVector getSize

Fetches the number of elements in the TVector.

Returns:
An integer representing the number of elements in the TVector.


init

TVector init [obj1 ...]

Initializes the TVector object with a given set of elements.

Parameters:
obj1 - One of the objects to insert in the TVector.
Returns:
A reference to the object for which the method was called.

Replaces the contents of the TVector with the set of elements received as arguments.

pop

TVector pop

Retrieves and removes the last element of the TVector.

Returns:
A reference to the object that was the last element in the TVector.

If the TVector has no elements then a runtime error ocurrs.

push

TVector push anObject

Inserts a new element at the end of the TVector.

Parameters:
anObject - The object that will be inserted at the end of the vector.
Returns:
A reference to the object for which the method was called.

Inserts a new element into the TVector. The new anObject element is inserted at the end of the TVector. The number of elements in the TVector is increased by one.

This method performs the same operation as the append method when called with one argument.


resize

TVector resize newSize

Changes the size of the TVector.

Parameters:
newSize - An integer representing the new size of the TVector.
Returns:
A reference to the object for which the method was called.

Changes the TVector dimensions. If newSize is smaller than the current size of the TVector then the excedent elements are discarded. If newSize is larger than the TVector current size then all the existing elements are retained and the new elements are initialized with the null object.

setAt

TVector setAt anObject index

Changes one element of the TVector at a given position.

Parameters:
anObject - The object to insert at the index position.
index - An integer representing the index of the element to retrieve.
Returns:
A reference to the object for which the method was called.

If index is negative or equal to or larger than the size of the TVector then a runtime error ocurrs.

sort

TVector sort aFunction

Sorts the elements of the TVector acording to a comparison function.

Parameters:
aFunction - The function to be used as comparison function.
Returns:
A reference to the object for which the method was called.

The function aFunction will always be called with two arguments. The arguments will be elements of the TVector. The function aFunction is supposed to return a negative, zero or positive value if its first argument is less than, equal to or greater than its second argument.


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