VOOZH about

URL: https://www.geeksforgeeks.org/cpp/unordered_multiset-key_eq-function-in-c-stl/

⇱ unordered_multiset key_eq() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

unordered_multiset key_eq() function in C++ STL

Last Updated : 23 Jun, 2022

The unordered_multiset::key_eq() is a built-in function in C++ STL which returns a boolean value according to the comparison. It depends on the key equivalence comparison predicate used by the unordered_multiset container. The key equivalence comparison is a predicate which takes two arguments and returns a boolean value indicating whether they are to be considered equivalent. It returns true if they are equivalent else it returns false. It is adopted by the container on construction and is similar to the (==) operator used in the comparison. Syntax:

unordered_multiset_name.key_eq()(args1, args2)

Parameter: The function accepts two mandatory parameters args1 and args2, between whom the comparison is to be done. The data_type is same as that of the unordered_multiset. Return Value: The function returns a boolean value. Below programs illustrate the unordered_multiset::key_eq() function: Program 1

Output:
GEEKS and geeks are treated dissimilarly in the container

Time Complexity-O(1)

Program 2

Output:
100 and 200 are treated dissimilarly in the container
100 and 100 are treated similarly in the container

Time Complexity: O(1)

Comment