2.2.3.18 vector 
 
Name
vector
 
Remark
An Origin C vector is a dynamically allocated and sized array that is not tied to an internal Origin data set allowing a greater degree of flexibility. 
 vector is a template class with a default type of double but a vector of any basic data type (including char, byte, short, word, int, uint, complex, string) can be constructed using the syntax vector<type>. The vector class is derived from the vectorbase class from which it inherits methods and properties.
 
Hierarchy
Examples
EX1
 
// Example for numeric type vector
void vector_ex1()
{
    int imax = 10;
    vector<double> vX(imax);      // vector of doubles having imax elements
    vector vY(imax);              // vector of doubles by default
    vector<int> vI;               // vector of ints
    for(int ii = 0; ii < vX.GetSize(); ii++)
        vX[ii] = rnd();
    vY = 10 * vX;                 // vector arithmetic is supported
    vI = vY;                      // Cast double vector into int vector
    for(ii = 0; ii < vI.GetSize(); ii++) // Output cast elements of vectors
        printf("vI[%d]=%d after cast from %f\n",ii,vI[ii],vY[ii]);
}
EX2
 
// StringArray Example
// StringArray is typedef vector<string> in string.h
void vector_ex2()
{
    // declare one StringArray variable named saList and assign values 
    StringArray saList = { "Hello", "World", "!"}; 
    for(int ii = 0; ii < saList.GetSize(); ii++) // Output string one by one
        printf("%s\n", saList[ii]);
    vector<string> vsNames(3); // set the vector's size in construct 
    // assign string value
    vsNames[0] = "Tom"; 
    vsNames[1] = "Jenny";
    vsNames[2] = "Joy";  
    for(int jj = 0; jj < vsNames.GetSize(); jj++) // Output string one by one
        printf("%s\n", vsNames[jj]);
}
Header to Include
origin.h
 
Reference
Members
| Name
 | 
Brief
 | 
Example
 |  
|  Add
 | 
 Adds One element at the end of the vector.
 | 
 Examples
 |  
|  Find
 | 
 Find a specified string in a string vector.
 | 
 Examples
 |  
|  GetSourceRange
 | 
 gets the range inside the source  data when the constructor vector(Column& cc, int nLowerIndex = -1, int nUpperIndex = -1, int nWriteback = WRITEBACK_NO) is used. See that constructor and the accompanying example for more details.
 | 
 Examples
 |  
|  InsertAt
 | 
Inserts one element, or multiple copies of an element at a specified index in a vector. In the process, by incrementing the index, it shifts up the existing element at this index, and it shifts up all the elements above it.
 | 
 Examples
 |  
|  InsertValue
 | 
 It inserts the same value at the multiple locations inside a vector. The vector itself is resized as needed.
 | 
 Examples
 |  
|  Pattern
 | 
 Fill vector with arbitrary set of text values
 | 
 |  
|  RemoveAt
 | 
 Removes one or more elements starting at a specified index in a vector. It can removes elements at specified indices in a vector also.
 | 
 Examples
 |  
|  SetAtGrow
 | 
 Sets the vector element at the specified index.
 | 
 Examples
 |  
|  vector
 | 
 Constructors for vector class.
 | 
 Examples
 |   
             |