Learn R Programming

cppcontainers (version 1.0.4)

contains: Check for elements

Description

Check, if elements are part of a container.

Usage

contains(x, values)

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).

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.

See Also

[, at, back, front, top.

Examples

Run this code
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

Run the code above in your browser using DataLab