Vector Class (Collection)

The Vector class allows you to create a collection of data elements referenced by an index (zero-based). Data elements may be inserted, read, and deleted from anywhere within the collection.

An element is added to the vector collection several ways: using insert(iIndex, oElement) to add the element in front of the iIndex element. where oElement is the data to be added, or using push_back(oElement) to add the element to the end of the collection.

myVectorObj.insert(iIndex, oElement);  //adds oElement at position iIndex in the collection

myVectorObj.push_back(oElement);       //adds oElement as the last element of the collection

Elements are read from the vector using square brackets [iIndex] that specify the index of the element to read. Elements are written to the vector using square brackets [iIndex] to place oElement in an existing iIndex position.

Plot1(myVectorObj[iIndex].tostring()); // displays oElement at iIndex as a string

myVectorObj[iIndex] = myInput;         //replaces oElement at element iIndex, overwriting content

Elements are removed from the vector using the Erase(iIndex) to remove the iIndex element of the collection or by using pop_back() to remove the last element in the collection.

myVectorObj.erase(iIndex);             //removes element at iIndex

myVectorObj.pop_back();                //removes element at end of collection

Namespace: elsystem.collections

Properties

   Additional properties, methods, and events are described in the classes listed under Inheritance Hierarchy (see below).

  Name Type Description
Public property Count int Gets the number of elements in the vector collection.
Public property Items[index] object Gets the element at the specified index location in the vector collection.
Methods
  Name Description
Public property Create Initializes a new instance of the Vector class.
Public property At(indx) Accesses an element at the specified position in the collection.
Public property Back Accesses the last element of the collection.
Public property Clear Removes all elements from the collection.
Public property Empty True if there are no elements in the collection, otherwise false.
Public property Erase(indx) Removes an element at the specified position.
Public property Erase(indx1,indx2)

Removes the elements in the specified range of index positions.

Removes the elements in the specified range from the collection.  The range includes all the elements between first and last, including the element pointed to by first but not the one pointed to by last.

Public property Front Accesses the first element of the collection.
Public property Insert(indx,obj) Adds an element (obj) before the specified index.
Public property Insert(indx,count,obj) Adds an element (obj) repeatedly before the specified position with the given count.
Public property Pop_back Removes the last element from the collection.
Public property Push_back(obj) Adds a new element (obj) to the end of the collection.
Inheritance Hierarchy

elsystem.Object

elsystem.Collections.Vector