powered by
Get the capacity of a CppVector.
capacity(x)
Returns a numeric.
A CppVector object.
The capacity is the space reserved for the vector, which can exceed its size. Additional capacity ensures that the vector can be extended efficiently, without having to reallocate its current elements to a new memory location.
reserve, shrink_to_fit, size.
v <- cpp_vector(4:9) v # 4 5 6 7 8 9 capacity(v) # [1] 6 reserve(v, 20) size(v) #[1] 6 capacity(v) # [1] 20 v # 4 5 6 7 8 9
Run the code above in your browser using DataLab