다음을 통해 공유


unordered_set::unordered_set

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

unordered_set(
    const unordered_set& Right
);
explicit unordered_set(
    size_type bucket_count = N0,
    const Hash& Hash = Hash(),
    const Comp& Comp = Comp(),
    const Allocator& Al = Alloc()
);
unordered_set(
    unordered_set&& Right
);
unordered_set(
    initializer_list<Type> IList
);
unordered_set(
    initializer_list<Type> 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 Comp& Comp
);
unordered_set(
    initializer_list<Type> IList, 
    size_type bucket_count,
    const Hash& Hash,
    const Comp& Comp,
    const Allocator& Al
);
template<class InputIterator>
    unordered_set(
    InputIterator first, 
    InputIterator last,
    size_type bucket_count = N0,
    const Hash& Hash = Hash(),
    const Comp& Comp = Comp(),
    const Allocator& Al = Alloc());

매개 변수

Parameter

설명

InputIterator

반복기의 형식입니다.

Al

저장된 할당 개체입니다.

Comp

저장된 비교 함수 개체입니다.

Hash

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

bucket_count

최소 버킷 수입니다.

Right

복사한 컨테이너입니다.

IList

복사될 요소를 포함하는 initializer_list.

설명

첫번째 생성자는 Right 에 의해 제어 되는 시퀀스의 복사본을 지정합니다. 두 번째 생성자는 빈 제어 시퀀스를 지정합니다. 세 번째 생성자는 Right 을 이동하여 시퀀스의 복사본을 지정합니다. 네 번째는 8 번째 생성자를 통해 initializer_list를 사용하여 복사할 요소를 지정합니다. 아홉번 째 생성자는 [first, last) 요소 값의 시퀀스를 삽입합니다.

모든 생성자는 여러 개의 저장 된 값도 초기화합니다. 복사 생성자에 대해, 값은 Right 로부터 얻습니다. 그렇지 않은 경우는 다음과 같습니다.

현재일 경우, 버킷의 최소 수는 인수 bucket_count 입니다. 그렇지 않은 경우는 기본값이 구현이 정의 된 N0 값으로 설명됩니다.

현재의 경우, 해당 해시 함수는 인수 Hash 입니다. 그렇지 않으면 Hash() 입니다.

현재의 경우, 비교 함수는 인수 Comp 입니다. 그렇지 않으면 Comp() 입니다.

현재의 경우, 할당 개체는 인수 Al 입니다. 그렇지 않은 경우 Alloc() 입니다.

예제 

코드

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

using namespace std;

typedef unordered_set<char> Myset;
int main()
{
    Myset c1;

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

    // display contents " [c] [b] [a]" 
    for (auto& c : c1){
        cout << " [" << c << "]";
    }
    cout << endl;

    Myset c2(8,
        hash<char>(),
        equal_to<char>(),
        allocator<pair<const char, int> >());

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

    // display contents " [f] [e] [d]" 
    for (auto& c : c2){
        cout << " [" << c << "]";
    }
    cout << endl;

    Myset c3(c1.begin(),
        c1.end(),
        8,
        hash<char>(),
        equal_to<char>(),
        allocator<pair<const char, int> >());

    // display contents " [c] [b] [a]" 
    for (auto& c : c3){
        cout << " [" << c << "]";
    }
    cout << endl;

    Myset c4(move(c3));

    // display contents " [c] [b] [a]" 
    for (auto& c : c4){
        cout << " [" << c << "]";
    }
    cout << endl;

    Myset c5{ { 'a', 'b', 'c' } };

    for (auto& c : c5){
        cout << " [" << c << "]";
    }
    cout << endl;
}

Output

[a] [b] [c]
 [d] [e] [f]
 [a] [b] [c]
 [a] [b] [c]

요구 사항

헤더: <unordered_set>

네임스페이스: std

참고 항목

참조

<unordered_set>

unordered_set 클래스

기타 리소스

<unordered_set> 멤버