| cpp_set | R Documentation |
Create a set. Sets are containers of unique, sorted elements.
cpp_set(x)
x |
An integer, numeric, character, or logical vector. |
Sets are associative containers. They do not provide random access through an index. I.e., s[2] does not return the second element.
C++ set methods implemented in this package are clear, contains, count, emplace, empty, erase, insert, max_size, merge, and size. 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.
Returns a CppSet object referencing a set in C++.
cpp_unordered_set, cpp_multiset, cpp_unordered_multiset.
s <- cpp_set(6:9)
s
# 6 7 8 9
insert(s, 4:7)
s
# 4 5 6 7 8 9
print(s, from = 6)
# 6 7 8 9
s <- cpp_set(c("world", "hello", "there"))
s
# "hello" "there" "world"
erase(s, "there")
s
# "hello" "world"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.