erase {cppcontainers} | R Documentation |
Erase elements
Description
Delete elements from a container by reference.
Usage
erase(x, values = NULL, from = NULL, to = NULL)
Arguments
x |
A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, CppUnorderedMultimap, CppVector, CppDeque, or CppList object. |
values |
A vector of values to delete from |
from |
Index of the first element to be deleted in CppVector, CppDeque, and CppList objects. Ignored for other classes. |
to |
Index of the last element to be deleted in CppVector, CppDeque, and CppList objects. Ignored for other classes. |
Value
Invisibly returns NULL
.
See Also
clear, empty, erase_after, remove..
Examples
s <- cpp_multiset(c(2, 2.1, 3, 3, 4.3, 6))
s
# 2 2.1 3 3 4.3 6
erase(s, c(2, 3))
s
# 2.1 4.3 6
m <- cpp_unordered_multimap(c(2:3, 3L), c("hello", "there", "world"))
m
# [3,"world"] [3,"there"] [2,"hello"]
erase(m, 2L)
m
# [3,"world"] [3,"there"]
d <- cpp_deque(4:9)
d
# 4 5 6 7 8 9
erase(d, from = 2, to = 3)
d
# 4 7 8 9
[Package cppcontainers version 1.0.0 Index]