std::multiset<Key,Compare,Allocator>::contains (3) - Linux Manuals
std::multiset<Key,Compare,Allocator>::contains: std::multiset<Key,Compare,Allocator>::contains
Command to display std::multiset<Key,Compare,Allocator>::contains
manual in Linux: $ man 3 std::multiset<Key,Compare,Allocator>::contains
NAME
std::multiset<Key,Compare,Allocator>::contains - std::multiset<Key,Compare,Allocator>::contains
Synopsis
bool contains( const Key& key ) const; (1) (since C++20)
template< class K > bool contains( const K& x ) const; (2) (since C++20)
1) Checks if there is an element with key equivalent to key in the container.
2) Checks if there is an element with key that compares equivalent to the value x. This overload only participates in overload resolution if the qualified-id Compare::is_transparent is valid and denotes a type. It allows calling this function without constructing an instance of Key.
Parameters
key - key value of the element to search for
x - a value of any type that can be transparently compared with a key
Return value
true if there is such an element, otherwise false.
Complexity
Logarithmic in the size of the container.
Example
// Run this code
#include <iostream>
#include <set>
int main()
{
std::multiset<int> example = {1, 2, 3, 4};
if(example.contains(2)) {
std::cout << "Found\n";
} else {
std::cout << "Not found\n";
}
}
Output:
Found
See also
finds element with specific key
find (public member function)
returns the number of elements matching specific key
count (public member function)
returns range of elements matching a specific key
equal_range (public member function)
Pages related to std::multiset<Key,Compare,Allocator>::contains
- std::multiset<Key,Compare,Allocator>::count (3) - std::multiset<Key,Compare,Allocator>::count
- std::multiset<Key,Compare,Allocator>::clear (3) - std::multiset<Key,Compare,Allocator>::clear
- std::multiset<Key,Compare,Allocator>::begin,std::multiset<Key,Compare,Allocator>::cbegin (3) - std::multiset<Key,Compare,Allocator>::begin,std::multiset<Key,Compare,Allocator>::cbegin
- std::multiset<Key,Compare,Allocator>::emplace (3) - std::multiset<Key,Compare,Allocator>::emplace
- std::multiset<Key,Compare,Allocator>::emplace_hint (3) - std::multiset<Key,Compare,Allocator>::emplace_hint
- std::multiset<Key,Compare,Allocator>::empty (3) - std::multiset<Key,Compare,Allocator>::empty
- std::multiset<Key,Compare,Allocator>::end,std::multiset<Key,Compare,Allocator>::cend (3) - std::multiset<Key,Compare,Allocator>::end,std::multiset<Key,Compare,Allocator>::cend
- std::multiset<Key,Compare,Allocator>::equal_range (3) - std::multiset<Key,Compare,Allocator>::equal_range
- std::multiset<Key,Compare,Allocator>::erase (3) - std::multiset<Key,Compare,Allocator>::erase
- std::multiset<Key,Compare,Allocator>::extract (3) - std::multiset<Key,Compare,Allocator>::extract
- std::multiset<Key,Compare,Allocator>::find (3) - std::multiset<Key,Compare,Allocator>::find
- std::multiset<Key,Compare,Allocator>::get_allocator (3) - std::multiset<Key,Compare,Allocator>::get_allocator
- std::multiset<Key,Compare,Allocator>::insert (3) - std::multiset<Key,Compare,Allocator>::insert
- std::multiset<Key,Compare,Allocator>::key_comp (3) - std::multiset<Key,Compare,Allocator>::key_comp
- std::multiset<Key,Compare,Allocator>::lower_bound (3) - std::multiset<Key,Compare,Allocator>::lower_bound
- std::multiset<Key,Compare,Allocator>::max_size (3) - std::multiset<Key,Compare,Allocator>::max_size
- std::multiset<Key,Compare,Allocator>::merge (3) - std::multiset<Key,Compare,Allocator>::merge
- std::multiset<Key,Compare,Allocator>::multiset (3) - std::multiset<Key,Compare,Allocator>::multiset
- std::multiset<Key,Compare,Allocator>::operator= (3) - std::multiset<Key,Compare,Allocator>::operator=
- std::multiset<Key,Compare,Allocator>::rbegin, (3) - std::multiset<Key,Compare,Allocator>::rbegin,
- std::multiset<Key,Compare,Allocator>::rbegin,std::multiset<Key,Compare,Allocator>::crbegin (3) - std::multiset<Key,Compare,Allocator>::rbegin,std::multiset<Key,Compare,Allocator>::crbegin
- std::multiset<Key,Compare,Allocator>::rend,std::multiset<Key,Compare,Allocator>::crend (3) - std::multiset<Key,Compare,Allocator>::rend,std::multiset<Key,Compare,Allocator>::crend
- std::multiset<Key,Compare,Allocator>::size (3) - std::multiset<Key,Compare,Allocator>::size
- std::multiset<Key,Compare,Allocator>::swap (3) - std::multiset<Key,Compare,Allocator>::swap
- std::multiset<Key,Compare,Allocator>::upper_bound (3) - std::multiset<Key,Compare,Allocator>::upper_bound
- std::multiset<Key,Compare,Allocator>::value_comp (3) - std::multiset<Key,Compare,Allocator>::value_comp
- std::multiset<Key,Compare,Allocator>::~multiset (3) - std::multiset<Key,Compare,Allocator>::~multiset
- std::multiset (3) - std::multiset