Share via


unordered_multiset::unordered_multiset

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());

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).

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

 

// std_tr1__unordered_set__unordered_multiset_construct.cpp 
// compile with: /EHsc 
#include <unordered_set> 
#include <iostream> 
 
typedef std::tr1::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::tr1::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::tr1::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; 
 
    return (0); 
    } 
 

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

Requirements

Header: <unordered_set>

Namespace: std::tr1

See Also

Reference

<unordered_set>

unordered_multiset Class