unordered_multiset 클래스

클래스 템플릿은 형식 const Key요소의 다양한 길이 시퀀스를 제어하는 개체를 설명합니다. 시퀀스는 해시 함수로 약하게 정렬됩니다. 즉, 시퀀스를 버킷이라고 하는 하위 시퀀스의 정렬된 집합으로 분할합니다. 비교 함수는 각 버킷 내에서 요소 쌍이 동일하게 정렬되었는지 여부를 확인합니다. 각 요소는 정렬 키와 값으로 사용됩니다. 시퀀스는 최소한 모든 버킷이 대략 동일한 크기일 경우 시퀀스의 요소 수와 상관없이 작업 수를 사용하여 임의 요소를 조회, 삽입, 제거하는 방식으로 나타냅니다(일정 시간). 모든 요소가 하나의 버킷에 있는 최악의 경우에는 작업 수가 시퀀스의 요소 수에 비례합니다(선형 시간). 또한, 요소를 삽입할 경우 어떤 반복기도 무효화되지 않으며, 요소를 제거할 경우 제거된 요소를 가리키고 있는 반복기만 무효화됩니다.

구문

template <class Key,
    class Hash = std::hash<Key>,
    class Pred = std::equal_to<Key>,
    class Alloc = std::allocator<Key>>
class unordered_multiset;

매개 변수

Key
키 형식입니다.

해시
해시 함수 개체 형식입니다.

Pred
같음 비교 함수 개체 형식입니다.

Alloc
할당자 클래스입니다.

멤버

형식 정의 설명
allocator_type 스토리지 관리를 위한 할당자의 형식입니다.
const_iterator 제어되는 시퀀스에 대한 상수 반복기의 형식입니다.
const_local_iterator 제어되는 시퀀스에 대한 상수 버킷 반복기의 형식입니다.
const_pointer 요소에 대한 상수 포인터의 형식입니다.
const_reference 요소에 대한 상수 참조의 형식입니다.
difference_type 두 요소 사이의 부호가 있는 거리의 형식입니다.
hasher 해시 함수의 형식입니다.
iterator 제어되는 시퀀스에 대한 반복기의 형식입니다.
key_equal 비교 함수의 형식입니다.
key_type 정렬 키의 형식입니다.
local_iterator 제어되는 시퀀스에 대한 버킷 반복기의 형식입니다.
pointer 요소에 대한 포인터의 형식입니다.
reference 요소에 대한 참조의 형식입니다.
size_type 두 요소 사이의 부호가 없는 거리의 형식입니다.
value_type 요소의 형식입니다.
멤버 함수 설명
begin 제어되는 시퀀스의 시작을 지정합니다.
양동이 키 값에 대한 버킷 개수를 가져옵니다.
bucket_count 버킷 개수를 가져옵니다.
bucket_size 버킷의 크기를 가져옵니다.
cbegin 제어되는 시퀀스의 시작을 지정합니다.
cend 제어되는 시퀀스의 끝을 지정합니다.
clear 모든 요소를 제거합니다.
에는 C++20이 포함되어 있습니다. 지정된 키를 가진 요소가 있는지 확인합니다.
count 지정한 키와 일치하는 요소의 수를 찾습니다.
emplace 생성된 요소를 추가합니다.
emplace_hint 힌트와 함께 생성된 요소를 추가합니다.
empty 요소가 있는지 여부를 테스트합니다.
end 제어되는 시퀀스의 끝을 지정합니다.
equal_range 지정된 키와 일치하는 범위를 찾습니다.
erase 지정된 위치에 있는 요소를 제거합니다.
find 지정된 키와 일치하는 요소를 찾습니다.
get_allocator 저장된 할당자 개체를 가져옵니다.
hash_function 저장된 해시 함수 개체를 가져옵니다.
insert 요소를 추가합니다.
key_eq 저장된 비교 함수 개체를 가져옵니다.
load_factor 버킷당 평균 요소 수를 계산합니다.
max_bucket_count 최대 버킷 개수를 가져옵니다.
max_load_factor 버킷당 최대 요소 수를 가져오거나 설정합니다.
max_size 제어되는 시퀀스의 최대 크기를 가져옵니다.
재 탕 해시 테이블을 다시 빌드합니다.
size 요소 수를 계산합니다.
swap 두 컨테이너의 내용을 바꿉니다.
unordered_multiset 컨테이너 개체를 만듭니다.
연산자 설명
unordered_multiset::operator= 해시 테이블을 복사합니다.

설명

개체는 저장된 두 개체, unordered_multiset::key_equal 형식의 비교 함수 개체, unordered_multiset::hasher 형식의 해시 함수 개체를 호출하여 제어하는 시퀀스를 정렬합니다. 첫 번째 저장된 개체는 구성원 함수 unordered_multiset::key_eq()를 호출하여 액세스하며, 두 번째 저장된 개체는 구성원 함수 unordered_multiset::hash_function()을 호출하여 액세스합니다. 특히 X 형식의 모든 값 YKey의 경우 두 인수 값이 순서 지정이 동일할 경우 호출 key_eq()(X, Y)에서 true를 반환하며, 호출 hash_function()(keyval)은 형식 size_t의 값 분포를 생성합니다. 클래스 템플릿 unordered_set Class와 달리 형식 unordered_multiset 의 개체는 제어되는 시퀀스의 두 요소에 대해 항상 false임을 보장 key_eq()(X, Y) 하지 않습니다. (키는 고유할 필요가 없습니다.)

개체는 또한 최대 로드 비율(버킷당 최대 평균 요소 수를 원하는 대로 지정)를 저장합니다. 요소를 삽입할 때 unordered_multiset::load_factor()에서 최대 로드 비율이 초과될 경우 컨테이너는 버킷 수를 증가시키고 필요에 따라 해시 테이블을 다시 빌드합니다.

제어된 시퀀스의 실제 요소 순서는 해시 함수, 비교 함수, 삽입 순서, 최대 로드 비율, 현재 버킷 수에 따라 달라집니다. 제어된 시퀀스의 요소 순서는 일반적으로 예측할 수 없습니다. 하지만 동일하게 정렬된 요소의 하위 집합은 제어된 시퀀스에서 항상 인접해 있습니다.

개체는 unordered_multiset::allocator_type 형식의 저장된 할당자 개체를 통해 제어하는 시퀀스에 대한 스토리지를 할당하고 해제합니다. 이러한 할당자 개체는 형식 allocator의 개체와 동일한 외부 인터페이스를 가져야 합니다. 컨테이너 개체를 할당하는 경우 저장된 할당자 개체는 복사되지 않습니다.

요구 사항

헤더:<unordered_set>

네임스페이스: std

unordered_multiset::allocator_type

스토리지 관리를 위한 할당자의 형식입니다.

typedef Alloc allocator_type;

설명

이 형식은 템플릿 매개 변수 Alloc의 동의어입니다.

예시

// std__unordered_set__unordered_multiset_allocator_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
typedef std::allocator<std::pair<const char, int> > Myalloc;
int main()
{
    Myset c1;

    Myset::allocator_type al = c1.get_allocator();
    std::cout << "al == std::allocator() is "
        << std::boolalpha << (al == Myalloc()) << std::endl;

    return (0);
}
al == std::allocator() is true

unordered_multiset::begin

제어되는 시퀀스 또는 버킷의 시작을 지정합니다.

iterator begin();

const_iterator begin() const;

local_iterator begin(size_type nbucket);

const_local_iterator begin(size_type nbucket) const;

매개 변수

nbucket
버킷 번호입니다.

설명

처음 두 개의 멤버 함수는 시퀀스의 첫 번째 요소(또는 빈 시퀀스의 끝 바로 다음)를 가리키는 정방향 반복기를 반환합니다. 마지막 두 멤버 함수는 버킷 nbucket의 첫 번째 요소(또는 빈 버킷의 끝 바로 너머)를 가리키는 정방향 반복기를 반환합니다.

예시

// std__unordered_set__unordered_multiset_begin.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect first two items "[c] [b]"
    Myset::iterator it2 = c1.begin();
    std::cout << "[" << *it2 << "] ";
    ++it2;
    std::cout << "[" << *it2 << "] ";
    std::cout << std::endl;

    // inspect bucket containing 'a'
    Myset::const_local_iterator lit = c1.begin(c1.bucket('a'));
    std::cout << "[" << *lit << "] ";

    return (0);
}
[c] [b] [a]
[c] [b]
[a]

unordered_multiset::bucket

키 값에 대한 버킷 개수를 가져옵니다.

size_type bucket(const Key& keyval) const;

매개 변수

keyval
매핑할 키 값입니다.

설명

멤버 함수는 현재 키 값 keyval에 해당하는 버킷 번호를 반환합니다.

예시

// std__unordered_set__unordered_multiset_bucket.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a] "
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // display buckets for keys
    Myset::size_type bs = c1.bucket('a');
    std::cout << "bucket('a') == " << bs << std::endl;
    std::cout << "bucket_size(" << bs << ") == " << c1.bucket_size(bs)
        << std::endl;

    return (0);
}
[c] [b] [a]
bucket('a') == 7
bucket_size(7) == 1

unordered_multiset::bucket_count

버킷 개수를 가져옵니다.

size_type bucket_count() const;

설명

멤버 함수는 현재 버킷 수를 반환합니다.

예시

// std__unordered_set__unordered_multiset_bucket_count.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a] "
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect current parameters
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // change max_load_factor and redisplay
    c1.max_load_factor(0.10f);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // rehash and redisplay
    c1.rehash(100);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;

    return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4

bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1

bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1

unordered_multiset::bucket_size

버킷의 크기를 가져옵니다.

size_type bucket_size(size_type nbucket) const;

매개 변수

nbucket
버킷 번호입니다.

설명

멤버 함수는 버킷 번호 nbucket의 크기를 반환합니다.

예시

// std__unordered_set__unordered_multiset_bucket_size.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a] "
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // display buckets for keys
    Myset::size_type bs = c1.bucket('a');
    std::cout << "bucket('a') == " << bs << std::endl;
    std::cout << "bucket_size(" << bs << ") == " << c1.bucket_size(bs)
        << std::endl;

    return (0);
}
[c] [b] [a]
bucket('a') == 7
bucket_size(7) == 1

unordered_multiset::cbegin

범위의 첫 번째 요소를 주소 지정하는 const 반복기를 반환합니다.

const_iterator cbegin() const;

Return Value

범위의 첫 번째 요소 또는 빈 범위의 끝 바로 다음 위치를 가리키는 const 정방향 액세스 반복기입니다(빈 범위의 경우 cbegin() == cend()).

설명

cbegin 반환 값을 사용하여 범위의 요소를 수정할 수 없습니다.

begin() 멤버 함수 대신 이 멤버 함수를 사용하여 반환 값이 const_iterator임을 보장할 수 있습니다. 일반적으로 다음 예제와 같이 auto 형식 추론 키워드와 함께 사용합니다. 이 예제에서는 Containerbegin()cbegin()를 지원하는 수정 가능(비const)한 컨테이너로 가정합니다.

auto i1 = Container.begin();
// i1 is Container<T>::iterator

auto i2 = Container.cbegin();
// i2 is Container<T>::const_iterator

unordered_multiset::cend

범위에서 마지막 요소 바로 다음의 위치를 주소 지정하는 const 반복기를 반환합니다.

const_iterator cend() const;

Return Value

범위 끝의 바로 다음을 가리키는 const 정방향 액세스 반복기입니다.

설명

cend는 반복기가 범위 끝을 통과했는지 여부를 테스트하는 데 사용됩니다.

end() 멤버 함수 대신 이 멤버 함수를 사용하여 반환 값이 const_iterator임을 보장할 수 있습니다. 일반적으로 다음 예제와 같이 auto 형식 추론 키워드와 함께 사용합니다. 이 예제에서는 Containerend()cend()를 지원하는 수정 가능(비const)한 컨테이너로 가정합니다.

auto i1 = Container.end();
// i1 is Container<T>::iterator

auto i2 = Container.cend();
// i2 is Container<T>::const_iterator

cend에서 반환한 값은 역참조되지 않아야 합니다.

unordered_multiset::clear

모든 요소를 제거합니다.

void clear();

설명

구성원 함수는 unordered_multiset::erase(unordered_multiset::begin(),unordered_multiset::end())를 호출합니다.

예시

// std__unordered_set__unordered_multiset_clear.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a] "
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // clear the container and reinspect
    c1.clear();
    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
    std::cout << std::endl;

    c1.insert('d');
    c1.insert('e');

    // display contents "[e] [d] "
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;

    return (0);
}
[c] [b] [a]
size == 0
empty() == true

[e] [d]
size == 2
empty() == false

unordered_multiset::const_iterator

제어되는 시퀀스에 대한 상수 반복기의 형식입니다.

typedef T1 const_iterator;

설명

이 형식은 제어되는 시퀀스의 상수 정방향 반복기로 사용될 수 있는 개체를 설명합니다. 여기서는 구현에서 정의된 형식 T1의 동의어로 설명됩니다.

예시

// std__unordered_set__unordered_multiset_const_iterator.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]

unordered_multiset::const_local_iterator

제어되는 시퀀스에 대한 상수 버킷 반복기의 형식입니다.

typedef T5 const_local_iterator;

설명

형식은 버킷의 상수 정방향 반복기로 사용될 수 있는 개체를 설명합니다. 여기서는 구현에서 정의된 형식 T5의 동의어로 설명됩니다.

예시

// std__unordered_set__unordered_multiset_const_local_iterator.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect bucket containing 'a'
    Myset::const_local_iterator lit = c1.begin(c1.bucket('a'));
    std::cout << "[" << *lit << "] ";

    return (0);
}
[c] [b] [a]
[a]

unordered_multiset::const_pointer

요소에 대한 상수 포인터의 형식입니다.

typedef Alloc::const_pointer const_pointer;

설명

이 형식은 제어되는 시퀀스의 요소에 대한 상수 포인터로 사용될 수 있는 개체를 설명합니다.

예시

// std__unordered_set__unordered_multiset_const_pointer.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::iterator it = c1.begin();
        it != c1.end(); ++it)
        {
        Myset::const_pointer p = &*it;
        std::cout << "[" << *p << "] ";
        }
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]

unordered_multiset::const_reference

요소에 대한 상수 참조의 형식입니다.

typedef Alloc::const_reference const_reference;

설명

이 형식은 제어되는 시퀀스의 요소에 대한 상수 참조로 사용될 수 있는 개체를 설명합니다.

예시

// std__unordered_set__unordered_multiset_const_reference.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::iterator it = c1.begin();
        it != c1.end(); ++it)
        {
        Myset::const_reference ref = *it;
        std::cout << "[" << ref << "] ";
        }
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]

unordered_multiset::contains

에 지정된 키를 unordered_multiset가진 요소가 있는지 확인합니다.

bool contains(const Key& key) const;
template<class K> bool contains(const K& key) const;

매개 변수

K
키의 형식입니다.

key
찾을 요소의 키 값입니다.

Return Value

true 컨테이너에 요소가 있으면 이고, false 그렇지 않으면.

설명

contains() 는 C++20의 새로운 기능입니다. 이 옵션을 사용하려면 /std:c++20 이상 컴파일러 옵션을 지정합니다.

template<class K> bool contains(const K& key) const 투명할 경우 key_compare 오버로드 확인에만 참여합니다.

예시

// Requires /std:c++20 or /std:c++latest
#include <unordered_set>
#include <iostream>

int main()
{
    std::unordered_multiset<int> theUnorderedMultiset = { 1, 2, 3 };

    std::cout << std::boolalpha; // so booleans show as 'true' or 'false'
    std::cout << theUnorderedMultiset.contains(1) << '\n';
    std::cout << theUnorderedMultiset.contains(4) << '\n';

    return 0;
}
true
false

unordered_multiset::count

지정한 키와 일치하는 요소의 수를 찾습니다.

size_type count(const Key& keyval) const;

매개 변수

keyval
검색할 키 값입니다.

설명

구성원 함수는 unordered_multiset::equal_range(keyval)로 구분된 범위의 요소 수를 반환합니다.

예시

// std__unordered_set__unordered_multiset_count.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    std::cout << "count('A') == " << c1.count('A') << std::endl;
    std::cout << "count('b') == " << c1.count('b') << std::endl;
    std::cout << "count('C') == " << c1.count('C') << std::endl;

    return (0);
}
[c] [b] [a]
count('A') == 0
count('b') == 1
count('C') == 0

unordered_multiset::difference_type

두 요소 사이의 부호가 있는 거리의 형식입니다.

typedef T3 difference_type;

설명

부호 있는 정수 형식은 제어되는 시퀀스에서 두 요소의 주소 간 차이점을 나타낼 수 있는 개체를 설명합니다. 여기서는 구현에서 정의된 형식 T3의 동의어로 설명됩니다.

예시

// std__unordered_set__unordered_multiset_difference_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // compute positive difference
    Myset::difference_type diff = 0;
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        ++diff;
    std::cout << "end()-begin() == " << diff << std::endl;

    // compute negative difference
    diff = 0;
    for (Myset::const_iterator it = c1.end();
        it != c1.begin(); --it)
        --diff;
    std::cout << "begin()-end() == " << diff << std::endl;

    return (0);
}
[c] [b] [a]
end()-begin() == 3
begin()-end() == -3

unordered_multiset::emplace

생성된 요소를 제 위치에 삽입합니다. 복사 또는 이동 작업은 수행되지 않습니다.

template <class... Args>
iterator emplace(Args&&... args);

매개 변수

args
unordered_multiset에 삽입할 요소를 생성하기 위해 전달되는 인수입니다.

Return Value

새로 삽입된 요소에 대한 반복기입니다.

설명

이 함수는 컨테이너 요소에 대한 참조는 무효화하지 않지만 컨테이너에 대한 모든 반복기는 무효화할 수 있습니다.

삽입 중에 예외가 throw되었으나 컨테이너의 해시 함수에서 발생하지 않은 경우에는 컨테이너가 수정되지 않습니다. 예외가 해시 함수에서 throw된 경우 결과는 정의되어 있지 않습니다.

코드 예제를 보려면 multiset::emplace를 참조하세요.

unordered_multiset::emplace_hint

배치 힌트를 사용하여 생성된 요소를 제 위치에 삽입합니다. 복사 또는 이동 작업은 수행되지 않습니다.

template <class... Args>
iterator emplace_hint(
    const_iterator where,
    Args&&... args);

매개 변수

args
unordered_multiset에 삽입할 요소를 생성하기 위해 전달되는 인수입니다.

where
올바른 삽입 지점 검색을 시작할 위치와 관련된 힌트입니다.

Return Value

새로 삽입된 요소에 대한 반복기입니다.

설명

이 함수는 컨테이너 요소에 대한 참조는 무효화하지 않지만 컨테이너에 대한 모든 반복기는 무효화할 수 있습니다.

삽입 중에 예외가 throw되었으나 컨테이너의 해시 함수에서 발생하지 않은 경우에는 컨테이너가 수정되지 않습니다. 예외가 해시 함수에서 throw된 경우 결과는 정의되어 있지 않습니다.

코드 예제를 보려면 set::emplace_hint를 참조하세요.

unordered_multiset::empty

요소가 있는지 여부를 테스트합니다.

bool empty() const;

설명

멤버 함수는 빈 제어되는 시퀀스에 대해 true를 반환합니다.

예시

// std__unordered_set__unordered_multiset_empty.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // clear the container and reinspect
    c1.clear();
    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
    std::cout << std::endl;

    c1.insert('d');
    c1.insert('e');

    // display contents "[e] [d]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;

    return (0);
}
[c] [b] [a]
size == 0
empty() == true

[e] [d]
size == 2
empty() == false

unordered_multiset::end

제어되는 시퀀스의 끝을 지정합니다.

iterator end();
const_iterator end() const;
local_iterator end(size_type nbucket);
const_local_iterator end(size_type nbucket) const;

매개 변수

nbucket
버킷 번호입니다.

설명

처음 두 멤버 함수는 시퀀스 끝의 바로 다음을 가리키는 정방향 반복기를 반환합니다. 마지막 두 멤버 함수는 버킷 nbucket의 끝 바로 너머를 가리키는 정방향 반복기를 반환합니다.

예시

// std__unordered_set__unordered_multiset_end.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect last two items "[a] [b]"
    Myset::iterator it2 = c1.end();
    --it2;
    std::cout << "[" << *it2 << "] ";
    --it2;
    std::cout << "[" << *it2 << "] ";
    std::cout << std::endl;

    // inspect bucket containing 'a'
    Myset::const_local_iterator lit = c1.end(c1.bucket('a'));
    --lit;
    std::cout << "[" << *lit << "] ";

    return (0);
}
[c] [b] [a]
[a] [b]
[a]

unordered_multiset::equal_range

지정된 키와 일치하는 범위를 찾습니다.

std::pair<iterator, iterator>
    equal_range(const Key& keyval);

std::pair<const_iterator, const_iterator>
    equal_range(const Key& keyval) const;

매개 변수

keyval
검색할 키 값입니다.

설명

멤버 함수는 키와 동등한 순서를 갖는 [X.first, X.second) 제어되는 시퀀스의 요소만 구분하도록 반복기 X 쌍을 반환합니다. 이러한 요소가 없는 경우 두 반복기는 end()입니다.

예시

// std__unordered_set__unordered_multiset_equal_range.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // display results of failed search
    std::pair<Myset::iterator, Myset::iterator> pair1 =
        c1.equal_range('x');
    std::cout << "equal_range('x'):";
    for (; pair1.first != pair1.second; ++pair1.first)
        std::cout << "[" << *pair1.first << "] ";
    std::cout << std::endl;

    // display results of successful search
    pair1 = c1.equal_range('b');
    std::cout << "equal_range('b'):";
    for (; pair1.first != pair1.second; ++pair1.first)
        std::cout << "[" << *pair1.first << "] ";
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
equal_range('x'):
equal_range('b'): [b]

unordered_multiset::erase

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

iterator erase(
    const_iterator Where);

iterator erase(
    const_iterator First,
    const_iterator Last);

size_type erase(
    const key_type& Key);

매개 변수

Where
제거할 요소의 위치입니다.

첫째
제거할 첫 번째 요소의 위치입니다.

마지막
제거할 마지막 요소 바로 다음 위치입니다.

Key
제거할 요소의 키 값입니다.

Return Value

처음 두 구성원 함수의 경우 제거된 요소 뒤에 남은 첫 번째 요소 또는 이러한 요소가 없을 경우 unordered_multiset의 끝에 있는 요소를 지정하는 양방향 반복기입니다.

세 번째 구성원 함수의 경우 unordered_multiset에서 제거된 요소의 수를 반환합니다.

설명

코드 예제를 보려면 set::erase를 참조하세요.

unordered_multiset::find

지정된 키와 일치하는 요소를 찾습니다.

const_iterator find(const Key& keyval) const;

매개 변수

keyval
검색할 키 값입니다.

설명

구성원 함수는 unordered_multiset::equal_range(keyval).first를 반환합니다.

예시

// std__unordered_set__unordered_multiset_find.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // try to find and fail
    std::cout << "find('A') == "
        << std::boolalpha << (c1.find('A') != c1.end()) << std::endl;

    // try to find and succeed
    Myset::iterator it = c1.find('b');
    std::cout << "find('b') == "
        << std::boolalpha << (it != c1.end())
        << ": [" << *it << "] " << std::endl;

    return (0);
}
[c] [b] [a]
find('A') == false
find('b') == true: [b]

unordered_multiset::get_allocator

저장된 할당자 개체를 가져옵니다.

Alloc get_allocator() const;

설명

멤버 함수는 저장된 할당자 개체를 반환합니다.

예시

// std__unordered_set__unordered_multiset_get_allocator.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
typedef std::allocator<std::pair<const char, int> > Myalloc;
int main()
{
    Myset c1;

    Myset::allocator_type al = c1.get_allocator();
    std::cout << "al == std::allocator() is "
        << std::boolalpha << (al == Myalloc()) << std::endl;

    return (0);
}
al == std::allocator() is true

unordered_multiset::hash_function

저장된 해시 함수 개체를 가져옵니다.

Hash hash_function() const;

설명

멤버 함수는 저장된 해시 함수 개체를 반환합니다.

예시

// std__unordered_set__unordered_multiset_hash_function.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    Myset::hasher hfn = c1.hash_function();
    std::cout << "hfn('a') == " << hfn('a') << std::endl;
    std::cout << "hfn('b') == " << hfn('b') << std::endl;

    return (0);
}
hfn('a') == 1630279
hfn('b') == 1647086

unordered_multiset::hasher

해시 함수의 형식입니다.

typedef Hash hasher;

설명

이 형식은 템플릿 매개 변수 Hash의 동의어입니다.

예시

// std__unordered_set__unordered_multiset_hasher.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    Myset::hasher hfn = c1.hash_function();
    std::cout << "hfn('a') == " << hfn('a') << std::endl;
    std::cout << "hfn('b') == " << hfn('b') << std::endl;

    return (0);
}
hfn('a') == 1630279
hfn('b') == 1647086

unordered_multiset::insert

unordered_multiset에 요소 또는 요소의 범위를 삽입합니다.

// (1) single element
pair<iterator, bool> insert(
    const value_type& Val);

// (2) single element, perfect forwarded
template <class ValTy>
pair<iterator, bool>
insert(
    ValTy&& Val);

// (3) single element with hint
iterator insert(
    const_iterator Where,
    const value_type& Val);

// (4) single element, perfect forwarded, with hint
template <class ValTy>
iterator insert(
    const_iterator Where,
    ValTy&& Val);

// (5) range
template <class InputIterator>
void insert(
    InputIterator First,
    InputIterator Last);

// (6) initializer list
void insert(
    initializer_list<value_type>
IList);

매개 변수

Val
unordered_multiset에 삽입할 요소의 값입니다.

Where
올바른 삽입 지점 검색을 시작할 위치입니다.

ValTy
unordered_multiset value_type 요소를 생성하는 데 사용할 수 있는 인수 형식을 지정하고 Val인수로 완벽하게 전달하는 템플릿 매개 변수입니다.

첫째
복사할 첫 번째 요소의 위치입니다.

마지막
복사할 마지막 요소 바로 다음 위치입니다.

InputIterator
value_type 개체를 생성하는 데 사용할 수 있는 형식의 요소를 가리키는 입력 반복기의 요구 사항을 충족하는 템플릿 함수 인수입니다.

IList
요소를 복사할 원본 initializer_list입니다.

Return Value

단일 요소 삽입 멤버 함수 (1) 및 (2)는 unordered_multiset에 새 요소를 삽입한 위치로 반복기를 반환합니다.

힌트가 있는 단일 요소 멤버 함수 (3) 및 (4)는 unordered_multiset에 새 요소를 삽입한 위치를 가리키는 반복기를 반환합니다.

설명

이 함수는 어떠한 포인터 또는 참조를 무효화하지 않지만 컨테이너에 대한 모든 반복기를 무효화할 수 있습니다.

요소를 하나만 삽입하는 중 예외가 throw되었으나 컨테이너의 해시 함수에서 발생하지 않은 경우에는 컨테이너의 상태가 수정되지 않습니다. 예외가 해시 함수에서 throw된 경우 결과는 정의되어 있지 않습니다. 여러 요소를 삽입하는 중 예외가 throw되면 컨테이너는 지정되지 않았으나 유효한 상태로 남아 있습니다.

컨테이너의 value_type은 컨테이너에 속한 형식 정의이고 set의 경우 unordered_multiset<V>::value_typeconst V입니다.

범위 멤버 함수(5)는 범위의 반복기 [First, Last)에서 주소가 지정된 각 요소에 해당하는 unordered_multiset 요소 값 시퀀스를 삽입합니다. 따라서 Last 는 삽입되지 않습니다. 컨테이너 멤버 함수 end()는 컨테이너의 마지막 요소 바로 뒤에 있는 위치를 참조합니다. 예를 들어 m.insert(v.begin(), v.end()); 문은 v의 모든 요소를 m에 삽입합니다.

이니셜라이저 목록 구성원 함수 (6)은 initializer_list를 사용하여 요소를 unordered_multiset로 복사합니다.

생성된 요소를 제 위치에 삽입하려면, 즉 복사 또는 이동 작업을 수행하지 않으려면 unordered_multiset::emplaceunordered_multiset::emplace_hint를 참조하세요.

코드 예제를 보려면 multiset::insert를 참조하세요.

unordered_multiset::iterator

unordered_multiset의 요소를 읽을 수 있는 상수 정방향 반복기를 제공하는 형식입니다.

typedef implementation-defined iterator;

예시

반복기를 선언하고 사용하는 방법의 예제는 begin의 예제를 참조하세요.

unordered_multiset::key_eq

저장된 비교 함수 개체를 가져옵니다.

Pred key_eq() const;

설명

멤버 함수는 저장된 비교 함수 개체를 반환합니다.

예시

// std__unordered_set__unordered_multiset_key_eq.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    Myset::key_equal cmpfn = c1.key_eq();
    std::cout << "cmpfn('a', 'a') == "
        << std::boolalpha << cmpfn('a', 'a') << std::endl;
    std::cout << "cmpfn('a', 'b') == "
        << std::boolalpha << cmpfn('a', 'b') << std::endl;

    return (0);
}
cmpfn('a', 'a') == true
cmpfn('a', 'b') == false

unordered_multiset::key_equal

비교 함수의 형식입니다.

typedef Pred key_equal;

설명

이 형식은 템플릿 매개 변수 Pred의 동의어입니다.

예시

// std__unordered_set__unordered_multiset_key_equal.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    Myset::key_equal cmpfn = c1.key_eq();
    std::cout << "cmpfn('a', 'a') == "
        << std::boolalpha << cmpfn('a', 'a') << std::endl;
    std::cout << "cmpfn('a', 'b') == "
        << std::boolalpha << cmpfn('a', 'b') << std::endl;

    return (0);
}
cmpfn('a', 'a') == true
cmpfn('a', 'b') == false

unordered_multiset::key_type

정렬 키의 형식입니다.

typedef Key key_type;

설명

이 형식은 템플릿 매개 변수 Key의 동의어입니다.

예시

// std__unordered_set__unordered_multiset_key_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // add a value and reinspect
    Myset::key_type key = 'd';
    Myset::value_type val = key;
    c1.insert(val);

    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
[d] [c] [b] [a]

unordered_multiset::load_factor

버킷당 평균 요소 수를 계산합니다.

float load_factor() const;

설명

구성원 함수는 (float)unordered_multiset::size() / (float)unordered_multiset::bucket_count()(버킷당 평균 요소 수)를 반환합니다.

예시

// std__unordered_set__unordered_multiset_load_factor.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect current parameters
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // change max_load_factor and redisplay
    c1.max_load_factor(0.10f);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // rehash and redisplay
    c1.rehash(100);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    return (0);
}

unordered_multiset::local_iterator

버킷 반복기의 형식입니다.

typedef T4 local_iterator;

설명

형식은 버킷의 정방향 반복기로 사용될 수 있는 개체를 설명합니다. 여기서는 구현에서 정의된 형식 T4의 동의어로 설명됩니다.

예시

// std__unordered_set__unordered_multiset_local_iterator.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect bucket containing 'a'
    Myset::local_iterator lit = c1.begin(c1.bucket('a'));
    std::cout << "[" << *lit << "] ";

    return (0);
}
[c] [b] [a]
[a]

unordered_multiset::max_bucket_count

최대 버킷 개수를 가져옵니다.

size_type max_bucket_count() const;

설명

멤버 함수는 현재 허용된 최대 버킷 개수를 반환합니다.

예시

// std__unordered_set__unordered_multiset_max_bucket_count.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect current parameters
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // change max_load_factor and redisplay
    c1.max_load_factor(0.10f);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // rehash and redisplay
    c1.rehash(100);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4

bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1

bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1

unordered_multiset::max_load_factor

버킷당 최대 요소 수를 가져오거나 설정합니다.

float max_load_factor() const;

void max_load_factor(float factor);

매개 변수

요소
새로운 최대 로드 비율입니다.

설명

첫 번째 멤버 함수는 저장된 최대 로드 비율을 반환합니다. 두 번째 멤버 함수는 저장된 최대 로드 팩터를 요소로 바꿉니다.

예시

// std__unordered_set__unordered_multiset_max_load_factor.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect current parameters
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // change max_load_factor and redisplay
    c1.max_load_factor(0.10f);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // rehash and redisplay
    c1.rehash(100);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_bucket_count() == "
        << c1.max_bucket_count() << std::endl;
    std::cout << "max_load_factor() == "
        << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4

bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1

bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1

unordered_multiset::max_size

제어되는 시퀀스의 최대 크기를 가져옵니다.

size_type max_size() const;

설명

멤버 함수는 개체가 제어할 수 있는 가장 긴 시퀀스의 길이를 반환합니다.

예시

// std__unordered_set__unordered_multiset_max_size.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    std::cout << "max_size() == " << c1.max_size() << std::endl;

    return (0);
}
max_size() == 4294967295

unordered_multiset::operator=

해시 테이블을 복사합니다.

unordered_multiset& operator=(const unordered_multiset& right);

unordered_multiset& operator=(unordered_multiset&& right);

매개 변수

right
unordered_multiset에 복사되는 unordered_multiset입니다.

설명

기존 요소를 unordered_multisetoperator= 지우고 나면 오른쪽unordered_multiset내용을 복사하거나 이동합니다.

예시

// unordered_multiset_operator_as.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

int main( )
{
    using namespace std;
    unordered_multiset<int> v1, v2, v3;
    unordered_multiset<int>::iterator iter;

    v1.insert(10);

    cout << "v1 = " ;
    for (iter = v1.begin(); iter != v1.end(); iter++)
        cout << *iter << " ";
    cout << endl;

    v2 = v1;
    cout << "v2 = ";
    for (iter = v2.begin(); iter != v2.end(); iter++)
        cout << *iter << " ";
    cout << endl;

    // move v1 into v2
    v2.clear();
    v2 = move(v1);
    cout << "v2 = ";
    for (iter = v2.begin(); iter != v2.end(); iter++)
        cout << *iter << " ";
    cout << endl;
}

unordered_multiset::pointer

요소에 대한 포인터의 형식입니다.

typedef Alloc::pointer pointer;

설명

이 형식은 제어되는 시퀀스의 요소에 대한 포인터로 사용될 수 있는 개체를 설명합니다.

예시

// std__unordered_set__unordered_multiset_pointer.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::iterator it = c1.begin();
        it != c1.end(); ++it)
        {
        Myset::key_type key = *it;
        Myset::pointer p = &key;
        std::cout << "[" << *p << "] ";
        }
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]

unordered_multiset::reference

요소에 대한 참조의 형식입니다.

typedef Alloc::reference reference;

설명

이 형식은 제어되는 시퀀스의 요소에 대한 참조로 사용될 수 있는 개체를 설명합니다.

예시

// std__unordered_set__unordered_multiset_reference.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::iterator it = c1.begin();
        it != c1.end(); ++it)
        {
        Myset::key_type key = *it;
        Myset::reference ref = key;
        std::cout << "[" << ref << "] ";
        }
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]

unordered_multiset::rehash

해시 테이블을 다시 빌드합니다.

void rehash(size_type nbuckets);

매개 변수

nbuckets
요청된 버킷 수입니다.

설명

멤버 함수는 버킷 수를 nbuckets 이상으로 변경하고 필요에 따라 해시 테이블을 다시 작성합니다.

예시

// std__unordered_set__unordered_multiset_rehash.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // inspect current parameters
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // change max_load_factor and redisplay
    c1.max_load_factor(0.10f);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;
    std::cout << std::endl;

    // rehash and redisplay
    c1.rehash(100);
    std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
    std::cout << "load_factor() == " << c1.load_factor() << std::endl;
    std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;

    return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_load_factor() == 4

bucket_count() == 8
load_factor() == 0.375
max_load_factor() == 0.1

bucket_count() == 128
load_factor() == 0.0234375
max_load_factor() == 0.1

unordered_multiset::size

요소 수를 계산합니다.

size_type size() const;

설명

멤버 함수는 제어되는 시퀀스의 길이를 반환합니다.

예시

// std__unordered_set__unordered_multiset_size.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // clear the container and reinspect
    c1.clear();
    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
    std::cout << std::endl;

    c1.insert('d');
    c1.insert('e');

    // display contents "[e] [d]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    std::cout << "size == " << c1.size() << std::endl;
    std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;

    return (0);
}
[c] [b] [a]
size == 0
empty() == true

[e] [d]
size == 2
empty() == false

unordered_multiset::size_type

두 요소 사이의 부호가 없는 거리의 형식입니다.

typedef T2 size_type;

설명

부호 없는 정수 형식은 제어되는 시퀀스의 길이를 나타낼 수 있는 개체를 설명합니다. 여기서는 구현에서 정의된 형식 T2의 동의어로 설명됩니다.

예시

// std__unordered_set__unordered_multiset_size_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;
    Myset::size_type sz = c1.size();

    std::cout << "size == " << sz << std::endl;

    return (0);
}
size == 0

unordered_multiset::swap

두 컨테이너의 내용을 바꿉니다.

void swap(unordered_multiset& right);

매개 변수

right
교환할 컨테이너입니다.

설명

멤버 함수는 제어된 시퀀스를 오른쪽 간에 *this교환합니다. unordered_multiset::get_allocator() == right.get_allocator()인 경우 일정 시간에 이 작업을 수행하고 Tr 형식의 저장된 특성 개체를 복사한 결과로만 예외를 throw하며 두 개의 제어되는 시퀀스에서 요소를 지정하는 참조, 포인터 또는 반복기를 무효화하지 않습니다. 그렇지 않으면 두 개의 제어되는 시퀀스에 있는 요소 수에 비례하여 많은 요소 할당 및 생성자 호출을 수행합니다.

예시

// std__unordered_set__unordered_multiset_swap.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    Myset c2;

    c2.insert('d');
    c2.insert('e');
    c2.insert('f');

    c1.swap(c2);

    // display contents "[f] [e] [d]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    swap(c1, c2);

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
[f] [e] [d]
[c] [b] [a]

unordered_multiset::unordered_multiset

컨테이너 개체를 만듭니다.

unordered_multiset(
    const unordered_multiset& Right);

explicit unordered_multiset(
    size_type Bucket_count = N0,
    const Hash& Hash = Hash(),
    const Comp& Comp = Comp(),
    const Allocator& Al = Alloc());

unordered_multiset(
    unordered_multiset&& Right);

unordered_set(
    initializer_list<Type> IList);

unordered_set(
    initializer_list<Typ> IList,
    size_type Bucket_count);

unordered_set(
    initializer_list<Type> IList,
    size_type Bucket_count,
    const Hash& Hash);

unordered_set(
    initializer_list<Type> IList,
    size_type Bucket_count,
    const Hash& Hash,
    const Key& Key);

unordered_set(
    initializer_list<Type> IList,
    size_type Bucket_count,
    const Hash& Hash,
    const Key& Key,
    const Allocator& Al);

template <class InputIterator>
unordered_multiset(
    InputIterator First,
    InputIterator Last,
    size_type Bucket_count = N0,
    const Hash& Hash = Hash(),
    const Comp& Comp = Comp(),
    const Allocator& Al = Alloc());

매개 변수

InputIterator
반복기 형식입니다.

Al
저장할 할당자 개체입니다.

광고
저장할 비교 함수 개체입니다.

해시
저장할 해시 함수 개체입니다.

Bucket_count
최소 버킷 수입니다.

Right
복사할 컨테이너입니다.

IList
복사할 initializer_list입니다.

설명

첫 번째 생성자는 Right로 제어되는 시퀀스의 복사본을 지정합니다. 두 번째 생성자는 빈 제어 시퀀스를 지정합니다. 세 번째 생성자는 [First, Last) 요소 값의 시퀀스를 삽입합니다. 네 번째 생성자는 오른쪽으로 이동하여 시퀀스의 복사본을 지정합니다.

모든 생성자는 또한 여러 개의 저장된 값을 초기화합니다. 복사 생성자의 경우 오른쪽에서 값을 가져옵니다. 그렇지 않은 경우:

버킷의 최소 수는 Bucket_count 인수입니다(있는 경우). 그렇지 않으면 구현 정의 값으로 여기에 설명된 기본값N0입니다.

해시 함수 개체는 인수 해시(있는 경우)이고, 그렇지 않으면 .입니다 Hash().

비교 함수 개체는 인수 Comp(있는 경우)이고, 그렇지 않으면 Comp입니다 Comp().

할당자 개체는 인수 Al(있는 경우)이고, 그렇지 않으면 입니다Alloc().

unordered_multiset::value_type

요소의 형식입니다.

typedef Key value_type;

설명

형식은 제어되는 시퀀스의 요소를 설명합니다.

예시

// std__unordered_set__unordered_multiset_value_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>

typedef std::unordered_multiset<char> Myset;
int main()
{
    Myset c1;

    c1.insert('a');
    c1.insert('b');
    c1.insert('c');

    // display contents "[c] [b] [a]"
    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    // add a value and reinspect
    Myset::key_type key = 'd';
    Myset::value_type val = key;
    c1.insert(val);

    for (Myset::const_iterator it = c1.begin();
        it != c1.end(); ++it)
        std::cout << "[" << *it << "] ";
    std::cout << std::endl;

    return (0);
}
[c] [b] [a]
[d] [c] [b] [a]

참고 항목

<unordered_set>
컨테이너
C++ 표준 라이브러리의 스레드 보안
C++ 표준 라이브러리 참조