View source: R/unordered_set.R
| cpp_unordered_set | R Documentation |
Create an unordered set. Unordered sets are containers of unique, unsorted elements.
cpp_unordered_set(x)
x |
An integer, numeric, character, or logical vector. |
Unordered sets are associative containers. They do not provide random access through an index. I.e. s[2] does not return the second
element.
Unordered means that the container does not enforce elements to be stored in a particular order. This makes unordered sets in some applications faster than sets. I.e., elements in unordered sets are unique, but not sorted.
C++ unordered_set methods implemented in this package are bucket_count, clear, contains, count, emplace, empty, erase, insert, load_factor, max_bucket_count, max_load_factor, max_size, merge, rehash, reserve, 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 CppUnorderedSet object referencing an unordered_set in C++.
cpp_set, cpp_multiset, cpp_unordered_multiset.
s <- cpp_unordered_set(6:10)
s
# 10 9 8 7 6
insert(s, 4:7)
s
# 5 4 10 9 8 7 6
print(s, n = 3L)
# 5 4 10
s <- cpp_unordered_set(c("world", "hello", "there"))
s
# "there" "hello" "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.