cpp_forward_list {cppcontainers} | R Documentation |
Create forward list
Description
Create a forward list, i.e. a singly-linked list.
Usage
cpp_forward_list(x)
Arguments
x |
An integer, numeric, character, or logical vector. |
Details
@details Singly-linked means that list elements store a reference only to the following element. This container type, thus, requires less RAM than a doubly-linked list does, but can only be iterated in the forward direction.
C++ forward_list methods implemented in this package are assign, clear, emplace_after, emplace_front, empty, erase_after, front, insert_after, max_size, pop_front, push_front, remove., resize, reverse, sort, splice_after, and unique. The package also adds the == operator 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
.
Value
Returns a CppForwardList object referencing a forward_list in C++.
See Also
cpp_vector, cpp_deque, cpp_list.
Examples
v <- cpp_forward_list(4:6)
v
# 4 5 6
push_front(v, 10L)
v
# 10 4 5 6
pop_front(v)
v
# 4 5 6