cpp_unordered_multimap {cppcontainers} | R Documentation |
Create unordered multimap
Description
Create an unordered multimap. Unordered multimaps are key-value pairs with non-unique keys.
Usage
cpp_unordered_multimap(keys, values)
Arguments
keys |
An integer, numeric, character, or logical vector. |
values |
An integer, numeric, character, or logical vector. |
Details
Unordered multimaps are associative containers. They do not provide random access through an index. I.e. m[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 multimaps in some applications faster than multimaps.
C++ unordered_multimap 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
.
Value
Returns a CppUnorderedMultimap object referencing an unordered_multimap in C++.
See Also
cpp_map, cpp_unordered_map, cpp_multimap.
Examples
m <- cpp_unordered_multimap(c("world", "hello", "there", "hello"), 4:7)
m
# ["there",6] ["hello",5] ["hello",7] ["world",4]
print(m, n = 2)
#
erase(m, "hello")
m
# ["there",6] ["world",4]
contains(m, "there")
# [1] TRUE