std::flat_m...t::contains(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::flat_m...t::contains(3) πŸŽ€

okay so this is the C++ Standard Libary page for std::flat_m...t::contains(3), and it is literally the softest little membership check. bestie, we are checking if a key is in the container. no cap. πŸ’…


🌸 NAME 🌸

std::flat_multiset::contains β€” and the NAME line is exactly std::flat_multiset::contains - std::flat_multiset::contains, because she contains herself too, iconic. ✨

πŸ¦‹ Synopsis πŸ¦‹

bool contains( const Key& key ) const; (1) (since C++23)
template< class K >                    (2) (since C++23)
bool contains( const K& x ) const;

Two overloads, both since C++23:

  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 participates in overload resolution only 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, bestie:

#include <iostream>
#include <flat_set>

int main()
{
    std::flat_multiset<int> example{1, 2, 3, 4};

    for (int x : {2, 5})
        if (example.contains(x))
            std::cout << x << ": Found\n";
        else
            std::cout << x << ": Not found\n";
}

🌈 Output 🌈

2: Found
5: Not found

πŸ‘‘ See also πŸ‘‘

  • find β€” finds element with specific key (public member function)
  • count β€” returns the number of elements matching specific key (public member function)
  • equal_range β€” returns range of elements matching a specific key (public member function)

πŸ’– source check: http://cppreference.com, dated 2024.06.10, page name std::flat_m...t::contains(3) β€” that is the whole footer, bestie. byeeee ✨🫢

πŸ“¦ where this page comes from