다음을 통해 공유


hash_multiset::erase

[!참고]

이 API는 사용되지 않습니다.대신 unordered_multiset Class.

요소 또는 요소의 범위는 지정 된 위치에서 hash_multiset를 제거 하거나 지정 된 키와 일치 하는 요소를 제거 합니다.

iterator erase(
   iterator _Where
);
iterator erase(
   iterator _First,
   iterator _Last
);
size_type erase(
   const key_type& _Key
);

매개 변수

  • _Where
    Hash_multiset에서 제거할 요소의 위치입니다.

  • _First
    Hash_multiset에서 제거 하는 첫 번째 요소의 위치입니다.

  • _Last
    마지막 요소 바로 뒤 위치에서 hash_multiset를 제거합니다.

  • _Key
    Hash_multiset에서 제거할 요소의 키입니다.

반환 값

첫 번째 두 명의 멤버 함수에 대 한 양방향 반복기는 이러한 요소가 있으면 모든 요소 제거 또는 포인터는 hash_multiset의 끝 넘어 남은 첫 번째 요소를 지정 됩니다.셋째 멤버 함수에 hash_multiset에서 제거한 요소의 수입니다.

설명

멤버 함수가 예외를 throw 하지 않습니다.

Visual C++.NET 2003 멤버는 <hash_map><hash_set> 헤더 파일이 더 이상 std 네임 스페이스에 있지만 오히려 stdext 네임 스페이스로 이동 되었습니다.자세한 내용은 stdext 네임스페이스를 참조하십시오.

예제

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

// hash_multiset_erase.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multiset<int> hms1, hms2, hms3;
    hash_multiset<int> :: iterator pIter, Iter1, Iter2;
    int i;
    hash_multiset<int>::size_type n;

    for (i = 1; i < 5; i++)
    {
        hms1.insert(i);
        hms2.insert(i * i);
        hms3.insert(i - 1);
    }

    // The 1st member function removes an element at a given position
    Iter1 = ++hms1.begin();
    hms1.erase(Iter1);

    cout << "After the 2nd element is deleted,\n "
         << "the hash_multiset hms1 is:" ;
    for (pIter = hms1.begin(); pIter != hms1.end(); pIter++)
        cout << " " << *pIter;
    cout << "." << endl;

    // The 2nd member function removes elements
    // in the range [_First, _Last)
    Iter1 = ++hms2.begin();
    Iter2 = --hms2.end();
    hms2.erase(Iter1, Iter2);

    cout << "After the middle two elements are deleted,\n "
         << "the hash_multiset hms2 is:" ;
    for (pIter = hms2.begin(); pIter != hms2.end(); pIter++)
        cout << " " << *pIter;
    cout << "." << endl;

    // The 3rd member function removes elements with a given _Key
    n = hms3.erase(2);

    cout << "After the element with a key of 2 is deleted,\n "
         << "the hash_multiset hms3 is:" ;
    for (pIter = hms3.begin(); pIter != hms3.end(); pIter++)
        cout << " " << *pIter;
    cout << "." << endl;

    // The 3rd member function returns the number of elements removed
    cout << "The number of elements removed from hms3 is: "
         << n << "." << endl;

    // The dereferenced iterator can also be used to specify a key
    Iter1 = ++hms3.begin();
    hms3.erase(Iter1);

    cout << "After another element with a key "
         << "equal to that of the 2nd element\n is deleted, "
         << "the hash_multiset hms3 is:" ;
    for (pIter = hms3.begin(); pIter != hms3.end(); pIter++)
        cout << " " << *pIter;
    cout << "." << endl;
}
  
  
  
  
  

요구 사항

헤더: <hash_set>

네임 스페이스: stdext

참고 항목

참조

hash_multiset Class

표준 템플릿 라이브러리