VecStr Class Function Manual

(   )

| HOME | BACK |

Purpose

To get a value of an element at a particular index in a vector of string, VecStr.. 

The first element index is 0, and the last one is n-1, where n is no of total elements.

Class

VecStr

Usage

{String} ret  =  object({int} argm1)

argm1 = index number

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v(0)

ans = Noobeed

->

See also (class function)

init

| HOME | BACK |


EXTEND

| HOME | BACK |

Purpose

To increase the maximum size of the vector by a given number.

Class

VecStr

Usage

{void} object.EXTEND({int} argm1)

argm1 = number of elements wanted to extend

Example:

->v = VecStr(5)

->v.maxsize()

  ans = 5

->v.extend(500)

->v.maxsize()

  ans = 505

->

See also (class function)

maxsize, truncate

| HOME | BACK |


FIND

| HOME | BACK |

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

VecStr

Usage

{int} ret  =  object.FIND({String} argm1)

argm1 = value of an element wanted to find

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v.find("1.0")

ans = 2

->

See also (class function)

qfind

| HOME | BACK |


FINDALL

| HOME | BACK |

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

VecStr

Usage

{Vecint} ret  =  object.FINDALL({String} argm1)

argm1 = value of an element wanted to find

Example:

->v = VecStr(10)
->v.pushback("asdf")
->v.pushback("asd")
->v.pushback("as")
->v.pushback("asd")
->v.pushback("asdf")
->v

ans =
Vector size : 5

asdf
asd
as
asd
asdf




->v.findall("asdf")

ans =
Vector size : 2

0
4


->

See also (class function)

qfind, find, frindfrom

| HOME | BACK |


FINDFROM

| HOME | BACK |

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

VecStr

Usage

{int} ret  =  object.FINDFROM({String} argm1, {int} argm2)

argm1 = value of an element wanted to find

argm2 = index number from which the searching begins

Example:

->v = VecStr(10)
->v.pushback("asdf")
->v.pushback("asd")
->v.pushback("as")
->v.pushback("asd")
->v.pushback("asdf")
->v

ans =
Vector size : 5

asdf
asd
as
asd
asdf


->v.findfrom("asdf",1)

ans = 4

->

See also (class function)

qfind, find, findall

| HOME | BACK |


 

HSORT

| HOME | BACK |

Purpose

To sort elements of a vector by using Heap sort.

Class

VecStr

Usage

{VecStr} ret  =  object.HSORT()

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v1 = v.hsort()

->print v1

Vector size : 3

1.0
Noobeed
version

->

See also (class function)

sort

| HOME | BACK |


INIT

| HOME | BACK |

Purpose

To initialize a VecStr 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

VecStr

Usage

{void} object.INIT({int} argm1)

argm1 = number of maximum elements in the vector

Example:

->v = VecStr()

->v.init(500)

->

See also (class function)

lingen

| HOME | BACK |


LAST

| HOME | BACK |

Purpose

To get the last element of the vector.

Class

VecStr

Usage

{String} ret  =  object.LAST()

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v.last()

  ans = 1.0

->

See also (class function)

unstack

| HOME | BACK |


LOAD

| HOME | BACK |

Purpose

To read data from an ASCII file and stored in a VecStr 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.

Noobeed

version

1.0

Here the data file has 3 lines.  This will generate a vector of 3 elements.

Unlike Vector and VecInt object, the VecStr does not realize the symbol "/" as a comment sign, it simply read it as an ordinary character.

Class

VecStr

Usage

{void} object.LOAD({String} argm1)

argm1 = data filename (default extension is ".txt")

Example:

->v = VecSrt()

->v.load("my_data")

->

See also (class function)

init, pushback

| HOME | BACK |


MAXSIZE

| HOME | BACK |

Purpose

To report the maximum size of the vector.  This is the maximum number of elements that can be stored in the vector.

Class

VecStr

Usage

{int} ret  =  object.MAXSIZE()

Example:

->v = VecStr(5)

->v.maxsize()

  ans =   5

->

See also (class function)

size, truncate, extend

| HOME | BACK |


MPUSHBACK

| HOME | BACK |

Purpose

To insert multiple elements, string objects, in a vector object.  New elements will be appended to the calling vector.

Class

VecStr

Usage

{void} object.MPUSHBACK({double} argm1,{int} argm2)

argm1 = string objects being inserted

argm2 = no of repetition

Example:

->v = VecStr(10)
->v.mpushback("Noobeed", 10)
->print v

Vector size : 10

Noobeed
Noobeed
Noobeed
Noobeed
Noobeed
Noobeed
Noobeed
Noobeed
Noobeed
Noobeed


->

See also (class function)

pushback

| HOME | BACK |


PUSHBACK

| HOME | BACK |

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

VecStr

Usage

{void} object.PUSHBACK({String} argm1)

argm1 = a string being inserted

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->

See also (class function)

init

| HOME | BACK |


QFIND

| HOME | BACK |

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

VecStr

Usage

{int} ret  =  object.FIND({String} argm1)

argm1 = value of an element wanted to find

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v1 = v.sort()

->print v1

Vector size : 3

1.0
Noobeed
version

->v1.qfind("Noobeed")

 ans =   1

->

See also (class function)

find

| HOME | BACK |


REMALL

| HOME | BACK |

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

VecStr

Usage

{void} object.REMALL()

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v.remall()

->print v

->

See also (class function)

remove, remsort

| HOME | BACK |


REMOVE

| HOME | BACK |

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

VecStr

Usage

{void} object.REMOVE({int} argm1)

argm1 = index at which the element being removed

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v.remove(1)

->print v

Vector size : 2

Noobeed
1.0


->

See also (class function)

remall, remsort

| HOME | BACK |


REMSORT

| HOME | BACK |

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

VecStr

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 = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v.remsort(0)

->print v

Vector size : 2

version
1.0

->

See also (class function)

remall, remove

| HOME | BACK |


REVERSE

| HOME | BACK |

Purpose

To reverse the content of the vector.

Class

VecStr

Usage

{VecStr} ret  =  object.REVERSE()

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v1 = v.reverse()

->print v1

Vector size : 3

1.0
version
Noobeed

->

See also (class function)

sort, qsort

| HOME | BACK |


SAVE

| HOME | BACK |

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

VecStr

Usage

{void} object.SAVE({String} argm1)

argm1 = output file name

Example:

->v.save("my_data")

->

See also (class function)

load

| HOME | BACK |


SIZE

| HOME | BACK |

Purpose

To report the current size of the vector.  This is the current number of elements in the vector.

Class

VecStr

Usage

{int} ret  =  object.SIZE()

Example:

->v = VecStr(5)

->v.size()

  ans =   0

->

See also (class function)

maxsize, truncate, extend

| HOME | BACK |


SORT

| HOME | BACK |

Purpose

To sort elements of a vector by using Shell sort.

Class

VecStr

Usage

{VecStr} ret  =  object.SORT()

Example:

->print v1

Vector size : 3

1.0
version
Noobeed

->v2 = v1.sort()

->print v2

Vector size : 3

1.0
Noobeed
version

->

See also (class function)

hsort

| HOME | BACK |


TRUNCATE

| HOME | BACK |

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

VecStr

Usage

{void} object.TRUNCATE()

argm1 = number of elements wanted to extend

Example:

->v = VecStr(5)

->v.maxsize()

  ans = 5

->v.truncate()

->v.maxsize()

  ans = 0

->

See also (class function)

maxsize, extend

| HOME | BACK |


UNSTACK

| HOME | BACK |

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

VecStr

Usage

{String} ret  =  object.UNSTACK()

Example:

->v = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->x = v.unstack()

->print x

1.0

->print v

Vector size : 2

Noobeed
version

->

See also (class function)

last

| HOME | BACK |


WINDOW

| HOME | BACK |

Purpose

To extract a portion of a vector, specified by a starting index and ending index.

Class

VecStr

Usage

{VectStr} 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 = VecStr(5)

->v.pushback("Noobeed")

->v.pushback("version")

->v.pushback("1.0")

->print v

Vector size : 3

Noobeed
version
1.0

->v1 = v.window(1,2)

->print v1

Vector size : 2

version
1.0

->

See also (class function)

 

| HOME | BACK |