Vector

 

Vector Overview

An un-typed Vector (also known as a Word vector) is a data structure containing an arbitrary number of heterogeneous data values. A Vector is also a one dimensional array:

"Humpty"
"Dumpty"
"sat"
"on"
"a"
"wall"

The Vector is a dynamic data type: it can grow to containing new elements or contract as elements are deleted. An element is accessed by an index from 0 to n-1 where n is the number of elements in the Vector. When an element is added, it is appended to the end.

"Humpty"
"Dumpty"
"sat"
"on"
"a"
"wall"
"Humpty"

Or we might sort the vector

"a"
"Dumpty"
"Humpty"
"Humpty"
"on"
"sat"
"wall"

Or we might delete a key by specify the index of the item to be deleted (2)

"a"
"Dumpty"
"Humpty"
"on"
"sat"
"wall"

When to Use

The Vector object is useful for storing data of the "same" types (homogeneous) or "different" types (heterogeneous) . The Vector object is very fast and has minimum memory overhead due to the indexed access of its values. If you require a random access strategy or a keyed access strategy see the Dictionary or Structure data types. Within the Vector object type there are the subtypes that store homogeneous values:

BitVector
ByteVector
CpxVector
FltVector
IntVector
NumVector
ObjVector
PcodeVector

Visual Basic Comparison

An Analytic Information Server Vector is similar to the single dimensioned dynamic array in Visual Basic. The Visual Basic array is created at compile time (the Visual Basic Array still requires a "ReDim" to specify a dimension), whereas the Analytic Information Server structure is created, expanded, or contracted dynamically at run time.

Dim DayArray(50)

DayArray is an array of Variants with 51 elements indexed, from 0 thru 50.

Constant Form

The Vector native data type has a constant form. A Vector constant is enclosed in brackets and preceded by the sharp symbol #().

For Example:

#(0 1 2 3 4 5 6 7 8 9)

The constant form for Vector allows any Analytic Information Server objects:

#(X: 5 #Jan,1,1996 #{Mike: "father" Sally: "mother"} "Hello")

#(23 34 "Testing" -.987 #\return)

#( "Hello" 9 34.5)

#(0 1 2 3 4 5 6 7 8 9 . {a: 10 b: 20})

Object Data Types

The Vector is a Heap Object or an Object Data Type. The Analytic Information Server Object Types are stored in the Heap and are managed by the Heap manager. The Analytic Information Server Heap manager supports object resizing, garbage collection, and anti-fragmentation algorithms so that the user may concentrate on the analysis and modeling of data rather than on memory management. Without exception, all of the Object types are identified by an object id. The object id identifies a block of memory, managed by the Lambda Information Server memory manager, in which the Object's data is stored.

The Analytic Information Server Heap Object and Native Data types can be saved and loaded to and from persistent (disk file) storage at any time. Containers with immediate data are saved on disk in fixed length records equal to the size of the container. Containers with Heap object references are saved in fixed length records, which are automatically expanded to include the contents of the Heap object, and any objects referenced by the Heap object, etc. This feature is called Object Closure Management and is automatic with every Analytic Information Server container database save.

Analytic Information Server containers may be loaded from any database repository record at any time. If the data in the record is immediate, the database load fills the container with the immediate data. If the data in the record is an object closure, the database load fills the container with a Heap object reference, and all of the objects in the record are loaded back into the Heap with the same referential relationships they had when they were saved in the repository.

 

Data Type Examples

The Vector object can be demonstrated by the following examples.

Example_Vector_addMethod_007 Example_Vector_append_006 Example_Vector_append_007 Example_Vector_apply_003
Example_Vector_apply_004 Example_Vector_binaryInsert_002 Example_Vector_binaryInsert_003 Example_Vector_binarySearch_003
Example_Vector_binarySearch_004 Example_Vector_cdr_005 Example_Vector_cdr_006 Example_Vector_compareEQ_006
Example_Vector_compareGE_006 Example_Vector_compareGT_006 Example_Vector_compareLE_006 Example_Vector_compareLT_006
Example_Vector_compareNE_06 Example_Vector_compare_006 Example_Vector_comparison_006 Example_Vector_copy_004
Example_Vector_copy_005 Example_Vector_count_004 Example_Vector_defMethod_008 Example_Vector_delete_007
Example_Vector_delete_008 Example_Vector_insert_004 Example_Vector_inside_004 Example_Vector_isAtom_004
Example_Vector_isEqual_004 Example_Vector_isIdentical_004 Example_Vector_isInside_004 Example_Vector_isMember_004
Example_Vector_isObject_006 Example_Vector_isType_008 Example_Vector_isVector_001 Example_Vector_length_007
Example_Vector_map_004 Example_Vector_mapc_004 Example_Vector_member_004 Example_Vector_methodsOf_009
Example_Vector_new_007 Example_Vector_new_008 Example_Vector_objectToVector_001 Example_Vector_refAttributes_004
Example_Vector_refValues_004 Example_Vector_ref_013 Example_Vector_ref_014 Example_Vector_remove_004
Example_Vector_resize_004 Example_Vector_reverse_001 Example_Vector_send_006 Example_Vector_setAttributes_004
Example_Vector_setAttributes_005 Example_Vector_setCdr_004 Example_Vector_setLastCdr_002 Example_Vector_setq_012
Example_Vector_setq_013 Example_Vector_sizeof_006 Example_Vector_sort_010 Example_Vector_sort_011
Example_Vector_type_009 Example_Vector_uniqueInsert_003 Example_Vector_vectorFill_001