Learn R Programming

cppcontainers (version 1.0.4)

shrink_to_fit: Shrink container capacity to size

Description

Shrink the capacity of a container to its size by reference.

Usage

shrink_to_fit(x)

Value

Invisibly returns NULL.

Arguments

x

A CppVector or CppDeque object.

Details

The capacity is the space, in terms of the number of elements, reserved for a container. The size is the number of elements in the container.

See Also

capacity, reserve, size.

Examples

Run this code
v <- cpp_vector(4:6)
capacity(v)
# [1] 3

reserve(v, 10)
capacity(v)
# [1] 10

shrink_to_fit(v)
capacity(v)
# [1] 3

Run the code above in your browser using DataLab