unordered_set::unordered_set
Erstellt ein container-Objekt.
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
Parameter |
Beschreibung |
InputIterator |
Der Iteratortyp. |
Al |
Das zu speichernde Zuweisungsobjekt. |
Comp |
Das zu speichernde Vergleichsfunktionsobjekt. |
Hash |
Das zu speichernde Hashfunktionsobjekt. |
bucket_count |
Die Mindestanzahl von Buckets. |
Right |
Der zu kopierende Container. |
IList |
Das initializer_list-Element, in dem die zu kopierenden Elemente enthalten sind. |
Hinweise
Mit dem ersten Konstruktor wird eine Kopie der Sequenz angegeben, die von Right gesteuert wird. Mit dem zweiten Konstruktor wird eine leere gesteuerte Sequenz angegeben. Der dritte Konstruktor gibt eine Kopie der Sequenz an, indem Right verschoben wird. Der vierte bis achte Konstruktor verwendet ein initializer_list-Element, um die zu kopierenden Elemente anzugeben. Mit dem neunten Konstruktor wird die Elementwertesequenz [first, last) eingefügt.
Alle Konstruktoren initialisieren auch einige gespeicherte Werte. Für den Kopierkonstruktor werden die Werte aus Right abgerufen. Andernfalls gilt:
Die Mindestbucketanzahl entspricht dem Argument bucket_count, falls es vorhanden ist. Andernfalls ist es ein Standardwert, der hier als der durch die Implementierung definierte Wert N0 beschrieben wird.
Das Hashfunktionsobjekt ist das Argument Hash, falls es vorhanden ist. Andernfalls ist es Hash().
Das Vergleichfunktionsobjekt ist das Argument Comp, falls es vorhanden ist. Andernfalls ist es Comp().
Das Zuweisungsobjekt ist das Argument Al, falls es vorhanden ist. Andernfalls ist es Alloc().
Beispiel
Code
/ 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;
}
Ausgabe
[a] [b] [c]
[d] [e] [f]
[a] [b] [c]
[a] [b] [c]
Anforderungen
Header: <unordered_set>
Namespace: std