Vec

From ArachneWiki

Jump to: navigation, search
For the input directory, see vector.

Vec (short for "vector") is Arachne's implementation of a dynamic array. It is very similar to the C++ vector class, and includes all of the same functionality, but it is more adapted to Arachne and is recommended for use over the C++ version. The Vec class is central to the Arachne code package: specific vec types include the Basevector and Qualvector, and several macros also implement it.

Functions in the Vec module (but not in the C++ vector) include:

  • operator<<: Easy stream output of vecs of primitive types, i.e., cout << vec<int> << endl;. Writes a newline between elements. The first line is n, the number of elements in the vec.
  • UniqueSort: Sorts a Vec and removes all duplicate entries. Syntax is UniqueSort(v) on a vector v.
  • SizeSum: The SizeSum of a vec<vec<type> > is the sum of all the sizes of its constituent Vecs.

The general description of all Vec routines is in Vec.h. To use Vecs in independent modules, #include "Vec.h".

Naming convention

Many source-code objects (i.e., type T) have typedef'ed Vec<T> forms. The standard naming convention is to prefix the type with "vec"; for example:

Type vec<Type>
bitvector vecbitvector
basevector vecbasevector
qualvector vecqualvector
String vecString
Personal tools