R vectors are similar to C++ vectors. These sequence containers allow for random access. I.e., you can directly access the fourth element via
its index x[4]
, without iterating through the first three elements before. Vectors are comparatively space-efficient, requiring less RAM per
element than many other container types.
One advantage of C++ vectors over R vectors is their ability to reduce the number of copies made during modifications. reserve, e.g., reserves
space for future vector extensions.
C++ vector methods implemented in this package are assign, at, back, capacity, clear, emplace,
emplace_back, empty, erase, flip, front, insert, max_size, pop_back, push_back,
reserve, resize, shrink_to_fit, and size. The package also adds the == and [ operators and various helper
functions (print, to_r, type).
All object-creating methods in this package begin with cpp_
to avoid clashes with functions from other packages, such as utils::stack
and
base::vector
.