C++ vector Library
C++ vector Library
The <vector> library has many functions that allow you to perform tasks on vectors.
A list of popular vector functions can be found in the table below.
| Function | Description | 
|---|---|
| assign() | Fills a vector with multiple values | 
| at() | Returns an indexed element from a vector | 
| back() | Returns the last element of a vector | 
| begin() | Returns an iterator pointing to the beginning of a vector | 
| capacity() | Returns the number of elements that a vector's reserved memory is able to store | 
| clear() | Removes all of the contents of a vector | 
| data() | Returns a pointer to the block of memory where a vector's elements are stored | 
| empty() | Checks whether a vector is empty or not | 
| end() | Returns an iterator pointing to the end of a vector | 
| erase() | Removes a number of elements from a vector | 
| front() | Returns the first element of a vector | 
| insert() | Inserts a number of elements into a vector | 
| max_size() | Returns the maximum number of elements that a vector can have | 
| pop_back() | Removes the last element of a vector | 
| push_back() | Adds an element to the end of a vector | 
| rbegin() | Returns a reverse iterator pointing to the last element of a vector | 
| rend() | Returns a reverse iterator pointing to a position right before the first element of a vector | 
| reserve() | Reserves memory for a vector | 
| resize() | Changes the size of a vector, adding or removing elements if necessary | 
| shrink_to_fit() | Reduces the reseved memory of a vector if necessary to exactly fit the number of elements | 
| size() | Returns the number of elements in a vector | 
| swap() | Swaps the contents of one vector with another | 
Learn more about vectors in our C++ Vector Tutorial.
 
