View source: R/unordered_map.R
| cpp_unordered_map | R Documentation |
Create an unordered map. Unordered maps are key-value pairs with unique keys.
cpp_unordered_map(keys, values)
keys |
An integer, numeric, character, or logical vector. |
values |
An integer, numeric, character, or logical vector. |
Unordered maps 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 maps in some applications faster than maps.
C++ unordered_map methods implemented in this package are at, bucket_count, clear, contains, count, emplace, empty, erase, insert, insert_or_assign, load_factor, max_bucket_count, max_load_factor, max_size, merge, rehash, reserve, size, and try_emplace. The package also adds the == and [ operators 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 CppUnorderedMap object referencing an unordered_map in C++.
cpp_map, cpp_multimap, cpp_unordered_multimap.
m <- cpp_unordered_map(4:6, seq.int(1, by = 0.5, length.out = 3L))
m
# [6,2] [5,1.5] [4,1]
insert(m, seq.int(100, by = 0.1, length.out = 3L), 14:16)
m
# [16,100.2] [15,100.1] [14,100] [6,2] [5,1.5] [4,1]
print(m, n = 3)
# [16,100.2] [15,100.1] [14,100]
m <- cpp_unordered_map(c("world", "hello", "there"), 4:6)
m
# ["there",6] ["hello",5] ["world",4]
erase(m, "there")
m
# ["hello",5] ["world",4]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.