reserve {cppcontainers}R Documentation

Reserve space

Description

Reserve space for the container by reference.

Usage

reserve(x, n)

Arguments

x

A CppUnorderedSet, CppUnorderedMultiset, CppUnorderedMap, CppUnorderedMultimap, or CppVector object.

n

The minimum number of elements per bucket.

Details

In case of a CppUnorderedSet, CppUnorderedMultiset, CppUnorderedMap, CppUnorderedMultimap, the method sets the number of buckets to be able to hold at least n elements and rehashes. In case of a CppVector, the method sets the capacity to n.

Value

Invisibly returns NULL.

See Also

bucket_count, capacity, load_factor, max_bucket_count, max_load_factor.

Examples

s <- cpp_unordered_set(4:6)
bucket_count(s)
# [1] 13
reserve(s, 3)
bucket_count(s)
# [1] 5

v <- cpp_vector(4:6)
capacity(v)
# [1] 3
reserve(v, 10)
capacity(v)
# [1] 10


[Package cppcontainers version 1.0.0 Index]