std::flat_set::count(3)

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

πŸ’… std::flat_set::count(3) πŸ’…

okay bestie, welcome to std::flat_set::count(3) from the C++ Standard Libary (yes, that spelling, we're keeping it πŸ’–). This one is short and iconic: it's all about counting matching keys. periodt. ✨

🌸 NAME 🌸

std::flat_set::count β€” std::flat_set::count

literally the same name twice, no cap. The manpage said it like that, so we're saying it like that. 🫢

✨ Synopsis ✨

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

Returns the number of elements with key that compares equivalent to the specified argument. πŸ‘‘

  1. Returns the number of elements with key key. This is either 1 or 0 since this container does not allow duplicates. πŸ’…
  2. Returns the number of elements 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 elements to count
  • x β€” alternative value to compare to the keys

πŸ’– Return value πŸ’–

Number of elements with key that compares equivalent to key or x, which, for overload (1), is either 1 or 0. 🌈

πŸ¦‹ Complexity πŸ¦‹

Logarithmic in the size of the container plus linear in the number of elements found. So not free, but also not a whole saga. 😭

πŸ’€ Example πŸ’€

This section is incomplete Reason: no example

no example bestie, they left us hanging πŸ™ˆ. That's literally what the page says, so we're not inventing one. πŸ’œ

πŸ“ See also πŸ“

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

these are your little search besties, go check them out 🫢

🌟 Category: 🌟

  • * Todo no example

mood. πŸŽ€


mwah πŸ’‹ this page came from http://cppreference.com, version/date 2024.06.10, and it's std::flat_set::count(3) β€” bye bestie, go count something! πŸ‘‘βœ¨

πŸ“¦ where this page comes from