std::multimap::count(3)

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

πŸ¦‹ std::multimap::count(3)

okay bestie, welcome to the C++ Standard Libary manual β€” today’s main character is std::multimap::count(3), and she is serving lookup realness. πŸ’…

πŸ’– NAME

std::multimap::count β€” std::multimap::count. Yep, that’s the whole name, periodt. πŸŽ€

🌸 Synopsis

Here’s the signature situation, and yes, overload (2) is the C++14 glow-up:

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

So what does it do? It returns the number of elements with key that compares equivalent to the specified argument. No cap, that’s the whole vibe.

  1. Returns the number of elements with key key.
  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. Iconic.

πŸŽ€ 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. That’s the answer, bestie. 🫢

⚑ Complexity

Logarithmic in the size of the container plus linear in the number of elements found. So it’s not a flat β€œjust look it up” situation β€” the container-size part is logarithmic, and the found-elements part is linear. ⭐

πŸ“ Notes

The feature-test macro lineup is giving very C++14:

  • Feature-test macro: __cpp_lib_generic_associative_lookup
  • Value: 201304L
  • Std: (C++14)
  • Feature: Heterogeneous comparison lookup in associative containers; overload (2)

🧚 Example

This section is incomplete Reason: no example

Literally a blank canvas, bestie. 😭

πŸ”₯ See also

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

🏷️ Category

  • * Todo no example

mwah πŸ’‹ β€” sourced from http://cppreference.com, version/date 2024.06.10. Bye bestie, go count those equivalent keys! πŸ’–

πŸ“¦ where this page comes from