resize {cppcontainers}R Documentation

Alter the container size

Description

Alter the size of the container by reference.

Usage

resize(x, size, value = NULL)

Arguments

x

A cppcontainers object.

size

The new size of the container.

value

The value of new elements. It defaults to 0 for integers and doubles, to "" for strings, and to FALSE for booleans.

Details

If the new size is larger than the former size, the function sets newly added elements in the back to value.

Value

Invisibly returns NULL.

Examples

v <- cpp_vector(4:9)
v
# 4 5 6 7 8 9

size(v)
# 6

resize(v, 10)
v
# 4 5 6 7 8 9 0 0 0 0

resize(v, 3)
v
# 4 5 6


[Package cppcontainers version 1.0.0 Index]