Learn R Programming

cppcontainers (version 1.0.4)

cpp_unordered_multiset: Create unordered multiset

Description

Create an unordered multiset. Unordered multisets are containers of non-unique, unsorted elements.

Usage

cpp_unordered_multiset(x)

Value

Returns a CppUnorderedMultiset object referencing an unordered_multiset in C++.

Arguments

x

An integer, numeric, character, or logical vector.

Details

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 multisets in some applications faster than multisets. I.e., elements in unordered multisets are neither unique nor sorted.

C++ unordered_multiset 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.

See Also

cpp_set, cpp_unordered_set, cpp_multiset.

Examples

Run this code
s <- cpp_unordered_multiset(c(6:10, 7L))
s
# 10 9 8 7 7 6

insert(s, 4:7)
s
# 5 4 6 6 7 7 7 8 9 10

print(s, n = 3L)
# 5 4 6

erase(s, 6L)
s
# 5 4 7 7 7 8 9 10

Run the code above in your browser using DataLab