std::map::count(3)

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

🌸 NAME 🌸

okay so this is std::map::count(3), straight from the C++ Standard Libary manual β€” yes bestie, β€œLibary” with one β€œr,” we’re keeping it exactly like that 🫢.

std::map::count - std::map::count (the name is the name, no notes πŸ’…).


✨ Synopsis ✨

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

Returns the number of elements with key that compares equivalent to the specified argument. Let’s break it down:

  1. Returns the number of elements with key key. This is either 1 or 0 since this container does not allow duplicates. periodt, no dupes allowed πŸ’€
  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 behavior honestly πŸŽ€

πŸŽ€ 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. that’s it, that’s the tea β˜•


πŸ¦‹ Complexity πŸ¦‹

Logarithmic in the size of the container plus linear in the number of elements found. so like, she’s not free, but she’s not doing a full sweep either, iykyk ✨


🌈 Notes 🌈

feature-test macro vibe check πŸ‘‘

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

bestie they left us hanging 😭 no example, but the reason is literally β€œno example” β€” we respect the honesty πŸ’€


πŸ‘‘ 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

source: http://cppreference.com β€” dated 2024.06.10. mwah πŸ’‹ slay.
πŸ“¦ where this page comes from