hash_set::key_comp (STL/CLR)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at hash_set::key_comp (STL/CLR).

Copies the ordering delegate for two keys.

Syntax

key_compare^key_comp();  

Remarks

The member function returns the ordering delegate used to order the controlled sequence. You use it to compare two keys.

Example

// cliext_hash_set_key_comp.cpp   
// compile with: /clr   
#include <cliext/hash_set>   
  
typedef cliext::hash_set<wchar_t> Myhash_set;   
int main()   
    {   
    Myhash_set c1;   
    Myhash_set::key_compare^ kcomp = c1.key_comp();   
  
    System::Console::WriteLine("compare(L'a', L'a') = {0}",   
        kcomp(L'a', L'a'));   
    System::Console::WriteLine("compare(L'a', L'b') = {0}",   
        kcomp(L'a', L'b'));   
    System::Console::WriteLine("compare(L'b', L'a') = {0}",   
        kcomp(L'b', L'a'));   
    System::Console::WriteLine();   
  
// test a different ordering rule   
    Myhash_set c2 = cliext::greater<wchar_t>();   
    kcomp = c2.key_comp();   
  
    System::Console::WriteLine("compare(L'a', L'a') = {0}",   
        kcomp(L'a', L'a'));   
    System::Console::WriteLine("compare(L'a', L'b') = {0}",   
        kcomp(L'a', L'b'));   
    System::Console::WriteLine("compare(L'b', L'a') = {0}",   
        kcomp(L'b', L'a'));   
    return (0);   
    }  
  
compare
(L'a', L'a') = True  
compare
(L'a', L'b') = True  
compare
(L'b', L'a') = False  
  
compare
(L'a', L'a') = False  
compare
(L'a', L'b') = False  
compare
(L'b', L'a') = True  

Requirements

Header: <cliext/hash_set>

Namespace: cliext

See Also

hash_set (STL/CLR)
hash_set::key_compare (STL/CLR)
hash_set::key_type (STL/CLR)