VecINT Class Function Manual |
Purpose
To get a value of an element at a particular index in a VecInt object.
The first element index is 0, and the last one is n-1, where n is no of total elements.
Class
VecInt
Usage
{double} ret = object({int} argm1)
argm1 = index number
Example:
->v = VecInt(5) ->v.pushback(2) ->v.pushback(3) ->v.pushback(43) ->print v |
See also (class function)
init
Purpose
To convert to a vector of double, a "Vector" object.
Class
VecInt
Usage
{Vecint} ret = object.DOUBLE()
Example:
->v = Vecint(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) ->print v ->print v1 |
See also (class function)
matrix
Purpose
To increase the maximum size of the vector by a given number.
Class
VecInt
Usage
{void} object.EXTEND({int} argm1)
argm1 = number of elements wanted to extend
Example:
->v = VecInt(5) ->v.maxsize() ->v.maxsize() |
See also (class function)
maxsize, truncate
Purpose
To find in a vector object a particular value of element.
The return result is an index of the vector, if found, otherwise it returns -1.
Class
VecInt
Usage
{int} ret = object.FIND({int} argm1)
argm1 = value of an element wanted to find
Example:
->v = VecInt(5) ->v.pushback(100) ->v.pushback(200) ->v.pushback(300) ->v.pushback(400) ->print v -> |
See also (class function)
qfind
Purpose
To find in a vector object a particular value of element. All the found positions, or indices, will be reported as a VecInt object, in which indices are stored. If not found, the return vector will be empty.
Class
Vecint
Usage
{Vecint} ret = object.FINDALL({int} argm1)
argm1 = value of an element wanted to find
Example:
->v =
vecint(10) |
See also (class function)
qfind, find, frindfrom
Purpose
To find in a vector object a particular value of element, starting from a certain position, the index number, given by the user as the last argument.
The return result is an index of the vector, if found, otherwise it returns -1.
Class
Vecint
Usage
{int} ret = object.FINDFROM({int} argm1, {int} argm2)
argm1 = value of an element wanted to find
argm2 = index number from which the searching begins
Example:
->v = vector(10) ->v.pushback(1) ->v.pushback(2) ->v.pushback(2) ->v.pushback(1) ->v.pushback(3) ->v ans = Vector size : 5 1 2 2 1 3 ->v.findfrom(1,2) ans = 3 -> |
See also (class function)
qfind, find, findall
HSORT
Purpose
To sort elements of a vector by using Heap sort.
Class
VecInt
Usage
{VecInt} ret = object.HSORT()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) ->print v ->print v1 |
See also (class function)
sort
Purpose
To initialize a vector object.
Please be aware that once the vector is initialized, it is still empty. Only its maximum number of element in the vector is declared. Use function "pushback" to insert element into a vector.
Class
VecInt
Usage
{void} object.INIT({int} argm1)
argm1 = number of maximum elements in the vector
Example:
->v = VecInt() ->v.init(500) -> |
See also (class function)
lingen
Purpose
To get the last element of the vector.
Class
VecInt
Usage
{int} ret = object.LAST()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) ->print v |
See also (class function)
unstack
Purpose
To generate a vector whose first and last element values are specified by the user. The values of elements in between will linearly increase by a specified interval.
Class
VecInt
Usage
{void} object.LINGEN({double} argm1, {double} argm2, [{double} argm3])
argm1 = start value for the first element
argm2 = end value for the last element
argm3 = linear spacing interval (default = 1)
Example:
->v = VecInt() ->v.lingen(10,12) ->print v ->v.lingen(20,15,-1) ->print v |
See also (class function)
init, pushback
Purpose
To read data from an ASCII file and stored in a Vector object.
If file name extension is omitted, the function will add default extensions to the files. The default extension of an ASCII data file is ".txt".
Unless the path name is given in the file names, the function will search for the files in the current working directory, defined by command "set path".
An example of an ASCII data file is as follows.
10
45
7
Here the data file has 3 lines. This will generate a vector of 3 elements.
It is possible to have a comment line in the data file, by inserting a slash sign, "/", in front of a line. Comment lines will not be read by the function.
Class
VecInt
Usage
{void} object.LOAD({String} argm1)
argm1 = data filename (default extension is ".txt")
Example:
->v = VecInt() ->v.load("my_data") -> |
See also (class function)
init, pushback
Purpose
To convert to a Matrix_int object.
This function creates a Matrix of size n row by 1 column, where n is number of elements in the vector.
Class
VecInt
Usage
{Matrix} ret = object.MATRIX()
Example:
->v = VecInt() ->v.lingen(10,14) ->print v ->print M |
See also (class function)
int
Purpose
To compute the maximum value of elements in the vector.
Class
VecInt
Usage
{int} ret = object.MAX()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) |
See also (class function)
min, median
Purpose
To report the maximum size of the vector. This is the maximum number of elements that can be stored in the vector.
Class
VecInt
Usage
{int} ret = object.MAXSIZE()
Example:
->v = VecInt(5) ->v.maxsize() |
See also (class function)
size, truncate, extend
Purpose
To determine a median, a value at the center position when all elements are sorted, of a Vector object.
Class
VecInt
Usage
{int} ret = object.MEDIAN()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) |
See also (class function)
min, max
Purpose
To compute the minimum value of elements in the vector.
Class
VecInt
Usage
{int} ret = object.MIN()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) |
See also (class function)
max, median
Purpose
To insert multiple elements in a vector object. New elements will be appended to the calling vector.
Class
VecInt
Usage
{void} object.MPUSHBACK({int} argm1,{int} argm2)
argm1 = value of an element being inserted
argm2 = no of repetition
Example:
->v = VecInt(5) ->v.mpushback(100, 4) ->print v -> |
See also (class function)
pushback
Purpose
To insert an element in a vector object. A new element will be insert at the last available index in the vector.
Suppose the vector has already 4 element in it, when a new element is inserted, the size is updated to 5 and the new element is stored at index number 4. The first element index is 0, and the last one is n-1, where n is no of total elements.
Class
VecInt
Usage
{void} object.PUSHBACK({int} argm1)
argm1 = value of an element being inserted
Example:
->v = VecInt(5) ->v.pushback(100) ->v.pushback(200) ->v.pushback(300) ->v.pushback(400) ->print v -> |
See also (class function)
init
Purpose
To find in a vector object a particular value of element. This function expects that the content of the vector is already sorted, or otherwise it will not work correctly.
It performs a binary searching which is much faster than using the function "find".
The return result is an index of the vector, if found, otherwise it returns -1.
Class
VecInt
Usage
{int} ret = object.FIND({int} argm1)
argm1 = value of an element wanted to find
Example:
->v = VecInt(5) ->v.pushback(100) ->v.pushback(200) ->v.pushback(300) ->v.pushback(400) ->print v -> |
See also (class function)
find
Purpose
To empty the content of the vector.
This function can be used to reset the vector very quick. It simply sets the size of the vector to zero. It does not do any memory initialization.
Class
VecInt
Usage
{void} object.REMALL()
Example:
->v = VecInt(5) ->v.pushback(100) ->v.pushback(200) ->v.pushback(300) ->v.pushback(400) ->v.remall() ->print v -> |
See also (class function)
remove, remsort
Purpose
To remove an element at a particular index out of the vector.
This function replace the content at the required index with the last element, and simply reduces the size of the vector by 1.
Class
VecInt
Usage
{void} object.REMOVE({int} argm1)
argm1 = index at which the element being removed
Example:
->v = VecInt() ->v.lingen(100,400,100) ->print v ->print v |
See also (class function)
remall, remsort
Purpose
To remove a group of elements, specified by a starting index and ending index, out of the vector. This function will fill up the gap by shift the rest of the content of the vector forward.
Class
VecInt
Usage
{void} object.REMSORT({int} argm1,[{int} argm1])
argm1 = start index at which the element being removed
argm2 = ending index at which the element being removed
(default = the same index as the start index)
Example:
->v = VecInt() ->v.lingen(1,20,2) ->print v ->print v |
See also (class function)
remall, remove
Purpose
To reverse the content of the vector.
Class
VecInt
Usage
{VecInt} ret = object.REVERSE()
Example:
->v = VecInt() ->v.lingen(1,20,2) ->print v ->print v1 |
See also (class function)
sort, qsort
Purpose
To save as ASCII format. Each line in the output file represents an element in the vector.
if a file name extension is not given, the function assumes an extension of ".txt".
if a path name is not include in the specified file name, the function will search in the current data path, set by command "set path".
Class
VecInt
Usage
{void} object.SAVE({String} argm1, [{int} argm2])
argm1 = output file name
argm2 = no of decimal digits (default = value set by command "set precision")
Example:
->v.save("my_data") |
See also (class function)
load
Purpose
To report the current size of the vector. This is the current number of elements in the vector.
Class
VecInt
Usage
{int} ret = object.SIZE()
Example:
->v = VecInt(5) ->v.size() |
See also (class function)
maxsize, truncate, extend
Purpose
To sort elements of a vector by using Shell sort.
Class
VecInt
Usage
{VecInt} ret = object.SORT()
Example:
->v = VecInt(5) ->v.pushback(400) ->v.pushback(300) ->v.pushback(200) ->print v ->print v1 |
See also (class function)
hsort
Purpose
To trim out all the empty space of the current vector.
Suppose a vector has 5 elements in it, and its max size is 500, once it is trimmed, the max size is reduced to 5. This function does a new memory initialization.
Class
VecInt
Usage
{void} object.TRUNCATE()
argm1 = number of elements wanted to extend
Example:
->v = VecInt(5) ->v.maxsize() ->v.maxsize() |
See also (class function)
maxsize, extend
Purpose
To get and take it out the last element of the vector.
This function is similar to function "last", however, it reduces the size of the vector by 1.
Class
VecInt
Usage
{int} ret = object.UNSTACK()
Example:
->v = VecInt() ->v.lingen(1,8) ->print v ->print x 8 ->print v |
See also (class function)
last
Purpose
To extract a portion of a vector, specified by a starting index and ending index.
Class
VecInt
Usage
{VecInt} ret = object.WINDOW({int} argm1,{int} argm2)
argm1 = start index at which the element being extracted
argm2 = ending index at which the element being extracted
Example:
->v = VecInt() ->v.lingen(1,8) ->print v ->print v1 |
See also (class function)