A vector is a sequence of values, all of which must have the same type, with an ability to access elements of the sequence by an integer index. A vector has a size, from a minimum of 0 to a maximum of 2 billion entries.
Vectors use semantics inherited from C: when accessing elements by index, the first position in the vector is index 0.
vector(valueType) variable;For instance, you can declare a vector holding 32-bit integers:
vector(integer) pos;
You can perform the following operations on vectors:
Syntax: new vector(type)
Type: A vector of the declared type is returned.
Example: pos := new vector(integer);
Syntax: vector[index]
Type: The index must have type integer. The value returned has the type of the values held in the vector.
Example: pos[10]
Syntax: vector[index] := value
Type: The index must have type integer, and the value must match the value type of the vector. The value returned is the updated vector.
Example: pos[5] := 3
Syntax: size(vector)
Type: The argument must be a vector. The value returned has type integer.
Example: size(pos)
Syntax: push_back(vector, value)
Type: The second argument must be a value with the value type of the vector. The return value has the type of the vector.
Example: push_back(pos, 3)
Syntax: resize(vector, newsize)
Type: The second argument must have type integer. The return value has the type of the vector.
Example: resize(vec1, 2)
There is no command to copy a vector. Therefore, the only way to make a copy of a vector is manually, by iterating through the elements. You can also iterate through all the elements in the vector (up to the first null element) using a for loop.
While dictionary and vector data structures can be defined globally, global use should be limited to reading them. Only one stream should write to a global dictionary or global vector data structure. And while that stream is writing, no other stream should write to or read from that data structure. The underlying objects used to manage the global dictionary or vector data structures are not thread-safe. A stream must have exclusive access to the global dictionary or vector data structure while writing. Allowing other streams to access these data structures while one stream is writing can result in server failure.
Global use of these data structures should be limited to relatively static data (such as country codes) that will not need to be updated during processing, but will be read by multiple streams. Writing the data to the dictionary or vector must be completed before any streams read it.
>typeof(streamname) rec := dict[symbol]; if( not (isnull(rec)) { // use rec }