Learn R Programming

cppcontainers (version 1.0.4)

splice_after: Move elements

Description

Move elements from one forward list to another forward list by reference.

Usage

splice_after(x, y, x_position, y_from, y_to)

Value

Invisibly returns NULL.

Arguments

x

A CppForwardList object to which to add elements.

y

A CppForwardList object, of the same data type as x, from which to extract elements.

x_position

Index after which to insert elements in x.

y_from

Index after which to extract elements from y.

y_to

Index of the last element to extract from y.

Details

Indices start at 1, which is also the minimum value permitted. Thus, the current implementation in this package does not allow to move the first element of y.

See Also

merge, splice.

Examples

Run this code
x <- cpp_forward_list(4:9)
x
# 4 5 6 7 8 9

y <- cpp_forward_list(10:12)
y
# 10 11 12

splice_after(x, y, 3, 1, 3)
x
# 4 5 6 11 12 7 8 9
y
# 10

Run the code above in your browser using DataLab