capacity {cppcontainers} | R Documentation |
Get container capacity
Description
Get the capacity of a CppVector.
Usage
capacity(x)
Arguments
x |
A CppVector object. |
Details
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.
Value
Returns a numeric.
See Also
Examples
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
[Package cppcontainers version 1.0.0 Index]