insert {cppcontainers} | R Documentation |
Add elements
Description
Add elements to a container by reference.
Usage
insert(x, values, keys = NULL, position = NULL)
Arguments
x |
A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, CppUnorderedMultimap, CppVector, CppDeque, or CppList object. |
values |
Values to add to |
keys |
Keys to add to |
position |
Index at which to insert elements into |
Details
Existing container values are not overwritten. I.e. inserting a key-value pair into a map that already contains that key preserves the old value and discards the new one. Use insert_or_assign to overwrite values.
Value
Invisibly returns NULL
.
See Also
assign, emplace, insert_after, insert_or_assign, push.
Examples
s <- cpp_multiset(4:6)
s
# 4 5 6
insert(s, 6:7)
s
# 4 5 6 6 7
m <- cpp_map(c("hello", "there", "world"), 9:11)
m
# ["hello",9] ["there",10] ["world",11]
insert(m, 12L, "there")
m
# ["hello",9] ["there",10] ["world",11]
[Package cppcontainers version 1.0.0 Index]