다음을 통해 공유


set::key_comp

순서 키 집합에 사용 되는 비교 개체의 복사본을 검색 합니다.

key_compare key_comp( ) const;

반환 값

템플릿 매개 변수는 집합의 요소 순서를 사용 하 여 함수 개체를 반환 Traits.

에 대 한 자세한 내용은 Traits 참조 된 set Class 항목.

설명

저장 된 개체의 멤버 함수를 정의합니다.

bool operator()(const Key&_xVal, const Key&_yVal);

반환 true 경우 _xVal 앞에 같지 않은 경우 _yVal 정렬 순서에서.

이때 모두 key_comparevalue_compare 동의어에 대 한 템플릿 매개 변수는 특성.두 형식 집합과 구분 되는, 지도 multimap 클래스와의 호환성에 대 한 동일 multiset 클래스를 제공 합니다.

예제

// set_key_comp.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   
   set <int, less<int> > s1;
   set<int, less<int> >::key_compare kc1 = s1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )   
   {
      cout << "kc1( 2,3 ) returns value of true, "
           << "where kc1 is the function object of s1."
           << endl;
   }
   else   
   {
      cout << "kc1( 2,3 ) returns value of false "
           << "where kc1 is the function object of s1."
           << endl;
   }

   set <int, greater<int> > s2;
   set<int, greater<int> >::key_compare kc2 = s2.key_comp( ) ;
   bool result2 = kc2( 2, 3 ) ;
   if(result2 == true)   
   {
      cout << "kc2( 2,3 ) returns value of true, "
           << "where kc2 is the function object of s2."
           << endl;
   }
   else   
   {
      cout << "kc2( 2,3 ) returns value of false, "
           << "where kc2 is the function object of s2."
           << endl;
   }
}
  
  

요구 사항

헤더: <set>

네임 스페이스: std

참고 항목

참조

set Class

set::key_comp 및 set::value_comp

표준 템플릿 라이브러리