The <vector> include file defines the vector class, which is a resizable array. Unlike built-in arrays, vectors grow or shrink to approximately the size of the number of elements in the vector. The file also holds a specialiation of the vector class for bool-type variables, which stores entries as single bits for efficiency. Additionally, the file defines six relational operators that are friend functions of the vector class.
The vector class is a template class that can be instantiated to create a resizable array. Each vector instance actually contains an array of entries of the template parameter type X. The size of the array depends on the number of entries and the allocator that is used as the parameter A. Generally, the default allocator is used, allocator<X>, but it is important to understand that the array is reallocated as entries are added or removed from the vector. This means that a pointer to an entry in the vector can become unknowingly invalid, while the index does not.
Membersclass vector<bool, A>
This is a specialization of the vector class to the bool type. When we declare a vector of bool-type variables, thie class is used to store that bools and single bits, rather than bool variables that can be up to 32 bits long. This class contains an additional nested reference class for accessing single bits and a flip function to perform the equivalent of a logical not operator on all of the bits.
Members© 20072024 XoaX.net LLC. All rights reserved.