Udostępnij za pośrednictwem


unordered_multiset::unordered_multiset

Konstruuje obiekt kontenera.

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

Parametry

Parametr

Opis

InputIterator

Typ iteratora.

Al

Obiekt alokatora do przechowania.

Comp

Obiekt funkcji porównywania do przechowania.

Hash

Obiekt funkcji skrótu do przechowania.

Bucket_count

Minimalna liczba zasobników.

Right

Kontener do skopiowania.

IList

initializer_list, z którego należy kopiować.

Uwagi

Pierwszy konstruktor określa kopię sekwencji kontrolowanej przez Right.Drugi konstruktor określa pustą kontrolowaną sekwencję.Trzeci konstruktor wstawia sekwencję wartości elementu [First, Last).Czwarty konstruktor określa kopię sekwencji, przesuwając Right.

Wszystkie konstruktory również inicjują kilka przechowywanych wartości.Wartości dla konstruktora kopiującego są uzyskiwane z Right.W przeciwnym razie:

Minimalna liczba segmentów jest argumentem Bucket_count, jeśli jest obecna; w przeciwnym razie jest to wartość domyślna opisana tutaj jako wartość zdefiniowana w implementacji N0.

Obiekt funkcji skrótu jest argumentem Hash, jeśli jest obecna; w przeciwnym razie jest Hash().

Obiekt funkcji porównania jest argumentem Comp, jeśli jest obecna; w przeciwnym razie jest Comp().

Obiekt programu przydzielania jest argumentem Al, jeśli jest obecny; w przeciwnym razie jest Alloc().

Przykład 

Kod

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

using namespace std;

typedef unordered_multiset<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{ { 'g', 'h' } };
    for (auto& c : c5) {
        cout << " [" << c << "]";
    }
    cout << endl;
}
// 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); 
    } 
 

Dane wyjściowe

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

Wymagania

Nagłówek: <unordered_set>

Przestrzeń nazw: std

Zobacz też

Informacje

<unordered_set>

unordered_multiset — Klasa

Inne zasoby

<unordered_set> Członkowie