Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Constructs a container object.
unordered_multiset(
const unordered_multiset& right);
explicit unordered_multiset(
size_type nbuckets = N0,
const Hash& hfn = Hash(),
const Pred& comp = Pred(),
const Alloc& al = Alloc());
template<class InIt>
unordered_multiset(
InIt first, InIt last,
size_type nbuckets = N0,
const Hash& hfn = Hash(),
const Pred& comp = Pred(),
const Alloc& al = Alloc());
unordered_multiset(
unordered_multiset&& right);
Parameters
Parameter |
Description |
InIt |
The iterator type. |
al |
The allocator object to store. |
comp |
The comparison function object to store. |
hfn |
The hash function object to store. |
nbuckets |
The minimum number of buckets. |
right |
The container to copy. |
Remarks
The first constructor specifies a copy of the sequence controlled by right. The second constructor specifies an empty controlled sequence. The third constructor inserts the sequence of element values [first, last).The fourth constructor specifies a copy of the sequence by moving right.
All constructors also initialize several stored values. For the copy constructor, the values are obtained from right. Otherwise:
the minimum number of buckets is the argument nbuckets, if present; otherwise it is a default value described here as the implementation-defined value N0.
the hash function object is the argument hfn, if present; otherwise it is Hash().
the comparison function object is the argument comp, if present; otherwise it is Pred().
the allocator object is the argument al, if present; otherwise, it is Alloc().
Example
Code
// std_tr1__unordered_set__unordered_multiset_construct.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(8,
std::hash<char>(),
std::equal_to<char>(),
std::allocator<std::pair<const char, int> >());
c2.insert('d');
c2.insert('e');
c2.insert('f');
// display contents " [f] [e] [d]"
for (Myset::const_iterator it = c2.begin();
it != c2.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
Myset c3(c1.begin(),
c1.end(),
8,
std::hash<char>(),
std::equal_to<char>(),
std::allocator<std::pair<const char, int> >());
// display contents " [c] [b] [a]"
for (Myset::const_iterator it = c3.begin();
it != c3.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
Myset c4(std::move(c3));
// display contents " [c] [b] [a]"
for (Myset::const_iterator it = c3.begin();
it != c3.end(); ++it)
std::cout << " [" << *it << "]";
std::cout << std::endl;
return (0);
}
Output
[c] [b] [a]
[f] [e] [d]
[c] [b] [a]
[c] [b] [a]
Requirements
Header: <unordered_set>
Namespace: std