| cpp_multimap | R Documentation |
Create a multimap. Multimaps are key-value pairs sorted by non-unique keys.
cpp_multimap(keys, values)
keys |
An integer, numeric, character, or logical vector. |
values |
An integer, numeric, character, or logical vector. |
Multimaps are associative containers. They do not provide random access through an index. I.e. m[2] does not return the second element.
C++ multimap 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 CppMultimap object referencing a multimap in C++.
cpp_map, cpp_unordered_map, cpp_unordered_multimap.
m <- cpp_multimap(4:6, seq.int(1, by = 0.5, length.out = 3L))
m
# [4,1] [5,1.5] [6,2]
insert(m, seq.int(100, by = 0.1, length.out = 3L), 5:7)
m
# [4,1] [5,1.5] [5,100] [6,2] [6,100.1] [7,100.2]
print(m, from = 6)
# [6,2] [6,100.1] [7,100.2]
m <- cpp_multimap(c("world", "hello", "there", "world"), 3:6)
m
# ["hello",4] ["there",5] ["world",3] ["world",6]
erase(m, "world")
m
# ["hello",4] ["there",5]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.