Skip to main content

A vector is a single-dimensional array: it contains components that can be accessed using an integral index. In some languages the size of a vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created. Use 'vector-graphics' for graphic display.

A vector is a single-dimensional : it contains components that can be accessed using an integral index. In some languages the size of a vector can grow or shrink as needed to accommodate adding and removing items after the vector has been created.

The applicable C++ Standard Library container class is called std::vector and emulates a C-style array. It has advantages over an array; such as the additional functionality of resizing itself when inserting or removing elements. As with the traditional array, the memory backing the std::vector is guaranteed to be contiguous, hence it is also often used to interoperate with older C-style APIs whilst maintaining the resources required.

Beware that std::vector<bool> does not have the std::vector interface.

Java also has the old Vector collection that, differently from ArrayList, is synchronized (so safer for multithreading), but slower.

However, languages like C, FORTRAN, etc., also often name the usual, fixed size arrays as "vectors".

The term "Vector" originated from using the array data structure to represent a geometric vector the starts at the coordinate origin (0,0,0) and points to the point, determined by the values, stored in this array (x,y,z).

This is distinct from:

Related tags: