Learn R Programming

cppcontainers (version 1.0.4)

merge: Merge two objects

Description

Merge two objects by reference.

Usage

merge(x, y, ...)

Value

Invisibly returns NULL.

Arguments

x

A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, CppUnorderedMultimap, CppForwardList, or CppList object.

y

A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, CppUnorderedMultimap, CppForwardList, or CppList object of the same class and data type as x.

...

Ignored. Only included for compatibility with generic base::merge method.

Details

In containers enforcing uniqueness (CppSet, CppUnorderedSet, CppMap, CppUnorderedMap), the function merges elements from y that are not in x into x and deletes them from y. In other container types, it transfers all elements.

See Also

assign, emplace, insert.

Examples

Run this code
x <- cpp_set(c("hello", "there"))
y <- cpp_set(c("hello", "world"))

merge(x, y)
x
# "hello" "there" "world"
y
# "hello"

x <- cpp_forward_list(c(1, 3, 4, 3))
y <- cpp_forward_list(c(2, 3, 5))

merge(x, y)
x
# 1 2 3 3 4 3 5
y
# 

Run the code above in your browser using DataLab