unordered_multimap::unordered_multimap
컨테이너 개체를 만듭니다.
unordered_multimap(
const unordered_multimap& Right
);
explicit unordered_multimap(
size_type Bucket_count = N0,
const Hash& Hash = Hash(),
const Comp& Comp = Pred(),
const Allocator& Al = Alloc()
);
unordered_multimap(
unordered_multimap&& Right
);
unordered_multimap(
initializer_list<Type> IList
);
unordered_multimap(
initializer_list< Type > IList,
size_type Bucket_count
);
unordered_multimap(
initializer_list< Type > IList,
size_type Bucket_count,
const Hash& Hash
);
unordered_multimap(
initializer_list< Type > IList,
size_type Bucket_count,
const Hash& Hash,
const Key& Key
);
unordered_multimap(
initializer_list<Type> IList,
size_type Bucket_count,
const Hash& Hash,
const Key& Key,
const Allocator& Al
);
template<class InputIterator>
unordered_multimap(
InputIterator first,
InputIterator last,
size_type Bucket_count = N0,
const Hash& Hash = Hash(),
const Comp& Comp = Pred(),
const Allocator& Al = Alloc()
);
매개 변수
매개 변수 |
설명 |
InputIterator |
반복기 형식입니다. |
Al |
저장할 할당자 개체입니다. |
Comp |
저장할 비교 함수 개체입니다. |
Hash |
저장할 해시 함수 개체입니다. |
Bucket_count |
최소 버킷 수입니다. |
Right |
복사할 컨테이너입니다. |
IList |
요소를 복사해올 initializer_list입니다. |
설명
첫 번째 생성자는 Right에 의해 제어되는 시퀀스의 복사본을 지정합니다. 두 번째 생성자는 빈 제어 시퀀스를 지정합니다. 세 번째 생성자는 Right를 이동하여 시퀀스의 복사본을 지정합니다. 네 번째, 다섯 번째, 여섯 번째, 일곱 번째 및 여덟 번째 생성자는 멤버에 initializer_list를 사용합니다. 아홉 번째 생성자는 [First, Last) 요소 값의 시퀀스를 삽입합니다.
모든 생성자는 또한 여러 개의 저장된 값을 초기화합니다. 복사 생성자의 값은 Right에서 가져옵니다. 그렇지 않은 경우는 다음과 같습니다.
버킷 최소 수는 인수 Bucket_count입니다(있는 경우). 그렇지 않으면 여기에 구현 정의 값 N0으로 설명된 기본값입니다.
해시 함수 개체는 인수 Hash입니다(있는 경우). 그렇지 않으면 Hash()입니다.
비교 함수 개체는 인수 Comp입니다(있는 경우). 그렇지 않으면 Pred()입니다.
할당자 개체는 인수 Al입니다(있는 경우). 그렇지 않으면 Alloc()입니다.
예제
// std__unordered_map__unordered_multimap_construct.cpp
// compile with: /EHsc
#include <unordered_map>
#include <iostream>
using namespace std;
using Mymap = unordered_multimap<char, int> ;
int main()
{
Mymap c1;
c1.insert(Mymap::value_type('a', 1));
c1.insert(Mymap::value_type('b', 2));
c1.insert(Mymap::value_type('c', 3));
// display contents " [c 3] [b 2] [a 1]"
for (const auto& c : c1) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
Mymap c2(8,
hash<char>(),
equal_to<char>(),
allocator<pair<const char, int> >());
c2.insert(Mymap::value_type('d', 4));
c2.insert(Mymap::value_type('e', 5));
c2.insert(Mymap::value_type('f', 6));
// display contents " [f 6] [e 5] [d 4]"
for (const auto& c : c2) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
Mymap c3(c1.begin(),
c1.end(),
8,
hash<char>(),
equal_to<char>(),
allocator<pair<const char, int> >());
// display contents " [c 3] [b 2] [a 1]"
for (const auto& c : c3) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
Mymap c4(move(c3));
// display contents " [c 3] [b 2] [a 1]"
for (const auto& c : c4) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
// Construct with an initializer_list
unordered_multimap<int, char> c5({ { 5, 'g' }, { 6, 'h' }, { 7, 'i' }, { 8, 'j' } });
for (const auto& c : c5) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
// Initializer_list plus size
unordered_multimap<int, char> c6({ { 5, 'g' }, { 6, 'h' }, { 7, 'i' }, { 8, 'j' } }, 4);
for (const auto& c : c1) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
// Initializer_list plus size and hash
unordered_multimap<int, char, tr1::hash<char>> c7(
{ { 5, 'g' }, { 6, 'h' }, { 7, 'i' }, { 8, 'j' } },
4,
tr1::hash<char>()
);
for (const auto& c : c1) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
// Initializer_list plus size, hash, and key_equal
unordered_multimap<int, char, tr1::hash<char>, equal_to<char>> c8(
{ { 5, 'g' }, { 6, 'h' }, { 7, 'i' }, { 8, 'j' } },
4,
tr1::hash<char>(),
equal_to<char>()
);
for (const auto& c : c1) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
// Initializer_list plus size, hash, key_equal, and allocator
unordered_multimap<int, char, tr1::hash<char>, equal_to<char>> c9(
{ { 5, 'g' }, { 6, 'h' }, { 7, 'i' }, { 8, 'j' } },
4,
tr1::hash<char>(),
equal_to<char>(),
allocator<pair<const char, int> >()
);
for (const auto& c : c1) {
cout << " [" << c.first << ", " << c.second << "]";
}
cout << endl;
}
요구 사항
헤더: <unordered_map>
네임스페이스: std