contains {cppcontainers} | R Documentation |
Check for elements
Description
Check, if elements are part of a container.
Usage
contains(x, values)
Arguments
x |
A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, or CppUnorderedMultimap object. |
values |
Values whose existence to assess. Refers to keys in the case of CppMap, CppUnorderedMap, CppMultimap, and CppUnorderedMultimap objects. |
Value
Returns a logical vector of the same length as values
, denoting for each value whether it is part of x
(TRUE
) or not
(FALSE
).
See Also
Examples
s <- cpp_multiset(4:9)
s
# 4 5 6 7 8 9
contains(s, 9:11)
# [1] TRUE FALSE FALSE
m <- cpp_unordered_map(c("hello", "world"), 3:4)
m
# ["world",4] ["hello",3]
contains(m, c("world", "there"))
# [1] TRUE FALSE
[Package cppcontainers version 1.0.0 Index]