Learn R Programming

cppcontainers (version 1.0.4)

cpp_deque: Create deque

Description

Create a deque, i.e. a double-ended queue.

Usage

cpp_deque(x)

Value

Returns a CppDeque object referencing a deque in C++.

Arguments

x

An integer, numeric, character, or logical vector.

Details

C++ deque methods implemented in this package are assign, at, back, clear, emplace, emplace_back, emplace_front, empty, erase, front, insert, max_size, pop_back, pop_front, push_back, push_front, resize, shrink_to_fit, and size. The package also adds the == and [ operators and various helper functions (print, to_r, type).

All object-creating methods in this package begin with cpp_ to avoid clashes with functions from other packages, such as utils::stack and base::vector.

See Also

cpp_vector, cpp_forward_list, cpp_list.

Examples

Run this code
d <- cpp_deque(4:6)
d
# 4 5 6

push_back(d, 1L)
d
# 4 5 6 1

push_front(d, 2L)
d
# 2 4 5 6 1

Run the code above in your browser using DataLab