Learn R Programming

cppcontainers (version 1.0.4)

back: Access last element

Description

Access the last element in a container without removing it.

Usage

back(x)

Value

Returns the last element.

Arguments

x

A CppQueue, CppVector, CppDeque, or CppList object.

Details

In a CppQueue, the last element is the last inserted one.

See Also

front, top, push_back, emplace_back, pop_back.

Examples

Run this code
q <- cpp_queue(1:4)
q
# First element: 1

back(q)
# [1] 4

l <- cpp_list(1:4)
l
# 1 2 3 4

back(l)
# [1] 4

Run the code above in your browser using DataLab