insert_or_assign {cppcontainers} | R Documentation |
Add or overwrite elements
Description
Add elements to a container by reference. Overwrites existing container values tied to the same keys.
Usage
insert_or_assign(x, values, keys)
Arguments
x |
A CppMap or CppUnorderedMap object. |
values |
Values to add to |
keys |
Keys to add to |
Details
Use insert to avoid overwriting values.
Value
Invisibly returns NULL
.
See Also
insert, insert_after, emplace
, try_emplace
.
Examples
m <- cpp_map(4:6, 9:11)
m
# [4,9] [5,10] [6,11]
insert_or_assign(m, 12:13, 6:7)
m
# [4,9] [5,10] [6,12] [7,13]
[Package cppcontainers version 1.0.0 Index]