다음을 통해 공유


multiset::count

키 매개 변수에 지정 된 키가 일치 하는 복수 집합에서 요소를 반환 합니다.

size_type count(
   const Key& _Key
) const;

매개 변수

  • _Key
    Multiset에서 일치 하는 요소의 키입니다.

반환 값

정렬 키가 일치 하는 매개 변수 키 multiset 요소의 수입니다.

설명

요소 개수를 반환 하는 멤버 함수 x 범위

[lower_bound (_Key ), upper_bound (_Key ) ).

예제

이 예제를 컴파일하는 경우는 /Wp64 플래그를 지정 하거나 컴파일러 C4267 경고는 64 비트 플랫폼에서 생성 됩니다.이 경고에 대 한 자세한 내용은 컴파일러 경고 (수준 3) C4267.

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

int main()
{
    using namespace std;
    multiset<int> ms1;
    multiset<int>::size_type i;

    ms1.insert(1);
    ms1.insert(1);
    ms1.insert(2);

    // Elements do not need to be unique in multiset,
    // so duplicates are allowed and counted.
    i = ms1.count(1);
    cout << "The number of elements in ms1 with a sort key of 1 is: "
         << i << "." << endl;

    i = ms1.count(2);
    cout << "The number of elements in ms1 with a sort key of 2 is: "
         << i << "." << endl;

    i = ms1.count(3);
    cout << "The number of elements in ms1 with a sort key of 3 is: "
         << i << "." << endl;
}
  
  
  

요구 사항

헤더: <set>

네임 스페이스: std

참고 항목

참조

multiset Class

표준 템플릿 라이브러리