Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

5.1 The vector Data Abstraction

The vector container class generalizes the concept of an ordinary C array. Like an array, a vector is an indexed data structure, with index values that range from 0 to one less than the number of elements contained in the structure. Also like an array, values are most commonly assigned to and extracted from the vector using the subscript operator. However, the vector differs from an array in the following important respects:

The vector container class in the Standard C++ Library should be compared and contrasted to the deque container class described in Chapter 7. Like a vector, a deque (pronounced deck) is an indexed data structure. The major difference between the two is that a deque provides efficient insertion at either the beginning or the end of the container, while a vector provides efficient insertion only at the end. In many situations, either structure can be used. Use of a vector generally results in a smaller executable file, while use of a deque may result in a slightly faster program, depending upon the particular set of operations being performed.

5.1.1 Include Files

Whenever you use a vector, you must include the vector header file:


Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998