std::vector
Data / CompositeDescription
A dynamic array from the C++ Standard Library. Available without any #include. In C++ Mode, std::vector replaces IntList, FloatList, StringList, and Java's ArrayList. It grows automatically and supports all the same operations.
Syntax
std::vector nums
std::vector values
std::vector words
std::vector balls
Parameters
None
Returns
std::vectorMethods
| push_back(T v) | Add element to end (like ArrayList.add()) |
| pop_back() | Remove last element |
| size() | Number of elements |
| empty() | True if the vector has no elements |
| clear() | Remove all elements |
| at(int i) | Access element with bounds check |
| operator[](int i) | Access element without bounds check |
| front() | First element |
| back() | Last element |
| begin() / end() | Iterators for use in range-for loops |
| insert(iterator pos, T v) | Insert at position |
| erase(iterator pos) | Remove element at position |
| resize(int n) | Resize the vector |
| reserve(int n) | Reserve capacity without resizing |
Related
Under the Hood
Implementation in Processing.h / Processing.cpp:
Loading...