unordered_multiset — Klasaunordered_multiset Class
Szablon klasy opisuje obiekt, który kontroluje różnej długości sekwencje elementów typu const Key
.The class template describes an object that controls a varying-length sequence of elements of type const Key
. Sekwencja jest słabo uporządkowana według funkcji mieszania, która dzieli sekwencję na uporządkowany zestaw podsekwencji, zwanych przedziałami, segmentami lub pakietami.The sequence is weakly ordered by a hash function, which partitions the sequence into an ordered set of subsequences called buckets. W ramach każdego przedziału funkcja porównania określa, czy jakaś para elementów ma równoważną kolejność.Within each bucket a comparison function determines whether any pair of elements has equivalent ordering. Każdy element służy jako zarówno klucz sortowania, jak i wartość.Each element serves as both a sort key and a value. Sekwencja jest reprezentowana w sposób, który pozwala na wyszukiwanie, wstawianie i usuwanie dowolnego elementu z wielu operacji, które mogą być niezależne od liczby elementów w sekwencji (stały czas), co najmniej kiedy wszystkie przedziały są w przybliżeniu jednakowej długości.The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that can be independent of the number of elements in the sequence (constant time), at least when all buckets are of roughly equal length. W najgorszym przypadku, gdy wszystkie elementy znajdują się w jednym przedziale, liczba operacji jest proporcjonalna do liczby elementów w sekwencji (liniowy czas).In the worst case, when all of the elements are in one bucket, the number of operations is proportional to the number of elements in the sequence (linear time). Ponadto, wstawianie elementu nie unieważnia iteratorów, a usuwanie elementu unieważnia tylko te iteratory, które wskazują na usunięty element.Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.
SkładniaSyntax
template <class Key,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<Key>>
class unordered_multiset;
ParametryParameters
GłównychKey
Typ klucza.The key type.
SkrótuHash
Typ obiektu funkcji mieszania.The hash function object type.
PredPred
Typ obiektu funkcji porównywania równości.The equality comparison function object type.
AlokacjAlloc
Klasa alokatora.The allocator class.
Elementy członkowskieMembers
Definicja typuType Definition | OpisDescription |
---|---|
allocator_typeallocator_type | Typ alokatora do zarządzania pamięcią.The type of an allocator for managing storage. |
const_iteratorconst_iterator | Typ iteratora stałego dla kontrolowanej sekwencji.The type of a constant iterator for the controlled sequence. |
const_local_iteratorconst_local_iterator | Typ iteratora stałego przedziału dla kontrolowanej sekwencji.The type of a constant bucket iterator for the controlled sequence. |
const_pointerconst_pointer | Typ stałego wskaźnika do elementu.The type of a constant pointer to an element. |
const_referenceconst_reference | Typ stałego odwołania do elementu.The type of a constant reference to an element. |
difference_typedifference_type | Typ odległości ze znakiem między dwoma elementami.The type of a signed distance between two elements. |
programu tworzącego skrótyhasher | Typ funkcji mieszania.The type of the hash function. |
Iteratoriterator | Typ iteratora dla kontrolowanej sekwencji.The type of an iterator for the controlled sequence. |
key_equalkey_equal | Typ funkcji porównywania.The type of the comparison function. |
key_typekey_type | Typ klucza sortowania.The type of an ordering key. |
local_iteratorlocal_iterator | Typ iteratora przedziału dla kontrolowanej sekwencji.The type of a bucket iterator for the controlled sequence. |
pointerpointer | Typ wskaźnika do elementu.The type of a pointer to an element. |
odwołareference | Typ odwołania do elementu.The type of a reference to an element. |
size_typesize_type | Typ odległości bez znaku między dwoma elementami.The type of an unsigned distance between two elements. |
value_typevalue_type | Typ elementu.The type of an element. |
Funkcja elementów członkowskichMember Function | OpisDescription |
---|---|
zacznąbegin | Określa początek kontrolowanej sekwencji.Designates the beginning of the controlled sequence. |
porcjbucket | Pobiera numer przedziału dla wartości klucza.Gets the bucket number for a key value. |
bucket_countbucket_count | Pobiera liczbę przedziałów.Gets the number of buckets. |
bucket_sizebucket_size | Pobiera rozmiar przedziału.Gets the size of a bucket. |
cbegincbegin | Określa początek kontrolowanej sekwencji.Designates the beginning of the controlled sequence. |
cendcend | Określa koniec kontrolowanej sekwencji.Designates the end of the controlled sequence. |
Wyczyśćclear | Usuwa wszystkie elementy.Removes all elements. |
zawierac++ 20containsC++20 | Sprawdza, czy istnieje element z określonym kluczem.Checks if there's an element with the specified key. |
liczbącount | Wyszukuje liczbę elementów pasujących do określonego klucza.Finds the number of elements matching a specified key. |
emplaceemplace | Dodaje element skonstruowany na miejscu.Adds an element constructed in place. |
emplace_hintemplace_hint | Dodaje element skonstruowany na miejscu, z podpowiedzią.Adds an element constructed in place, with hint. |
pusteempty | Sprawdza, czy nie ma żadnych elementów.Tests whether no elements are present. |
punktówend | Określa koniec kontrolowanej sekwencji.Designates the end of the controlled sequence. |
equal_rangeequal_range | Wyszukuje zakres, który odpowiada określonemu kluczowi.Finds range that matches a specified key. |
Wyłączanieerase | Usuwa elementy z określonych pozycji.Removes elements at specified positions. |
wyświetlićfind | Wyszukuje element, który odpowiada określonemu kluczowi.Finds an element that matches a specified key. |
get_allocatorget_allocator | Pobiera przechowywany obiekt alokatora.Gets the stored allocator object. |
hash_functionhash_function | Pobiera przechowywany obiekt funkcji mieszania.Gets the stored hash function object. |
wstawieniainsert | Dodaje elementy.Adds elements. |
key_eqkey_eq | Pobiera przechowywany obiekt funkcji porównywania.Gets the stored comparison function object. |
load_factorload_factor | Oblicza średnią liczbę elementów na przedział.Counts the average elements per bucket. |
max_bucket_countmax_bucket_count | Pobiera maksymalną liczbę przedziałów.Gets the maximum number of buckets. |
max_load_factormax_load_factor | Pobiera lub ustawia maksymalną liczbę elementów na przedział.Gets or sets the maximum elements per bucket. |
max_sizemax_size | Pobiera maksymalny rozmiar kontrolowanej sekwencji.Gets the maximum size of the controlled sequence. |
rehash —rehash | Przebudowuje tabelę mieszania.Rebuilds the hash table. |
zmieniasize | Liczy liczbę elementów.Counts the number of elements. |
wymianyswap | Zamienia zawartości dwóch kontenerów.Swaps the contents of two containers. |
unordered_multisetunordered_multiset | Konstruuje obiekt kontenera.Constructs a container object. |
OperatorOperator | OpisDescription |
---|---|
unordered_multiset:: operator =unordered_multiset::operator= | Kopiuje tabelę mieszania.Copies a hash table. |
UwagiRemarks
Obiekt porządkuje sekwencję, która kontroluje, wywołując dwa przechowywane obiekty, obiekt funkcji porównania typu unordered_multiset:: key_equal i obiektu funkcji hash typu unordered_multiset:: Hasher.The object orders the sequence it controls by calling two stored objects, a comparison function object of type unordered_multiset::key_equal and a hash function object of type unordered_multiset::hasher. Dostęp do pierwszego przechowywanego obiektu można uzyskać, wywołując funkcję członkowską unordered_multiset:: key_eq ()
; i uzyskując dostęp do drugiego przechowywanego obiektu przez wywołanie funkcji składowej unordered_multiset:: hash_function ()
.You access the first stored object by calling the member function unordered_multiset::key_eq()
; and you access the second stored object by calling the member function unordered_multiset::hash_function()
. W odniesieniu do wszystkich wartości X
i Y
typu Key
, wywołanie key_eq()(X, Y)
zwraca wartość true tylko wtedy, gdy dwie wartości argumentu mają równoważne porządkowanie; hash_function()(keyval)
wywołanie daje rozkład wartości typu size_t
.Specifically, for all values X
and Y
of type Key
, the call key_eq()(X, Y)
returns true only if the two argument values have equivalent ordering; the call hash_function()(keyval)
yields a distribution of values of type size_t
. W odróżnieniu od szablonu klasy Unordered_set Klasa, obiekt typu nie unordered_multiset
gwarantuje, że key_eq()(X, Y)
zawsze ma wartość false dla każdego z dwóch elementów kontrolowanej sekwencji.Unlike class template unordered_set Class, an object of type unordered_multiset
does not ensure that key_eq()(X, Y)
is always false for any two elements of the controlled sequence. (Klucze nie muszą być unikatowy.)(Keys need not be unique.)
Obiekt przechowuje również współczynnik maksymalnego obciążenia, który określa maksymalną żądaną średnią liczbę elementów na przedział.The object also stores a maximum load factor, which specifies the maximum desired average number of elements per bucket. Jeśli wstawianie elementu powoduje, że unordered_multiset:: load_factor ()
do przekroczenia maksymalnego współczynnika obciążenia, kontener zwiększa liczbę zasobników i ponownie kompiluje tabelę skrótów zgodnie z wymaganiami.If inserting an element causes unordered_multiset::load_factor()
to exceed the maximum load factor, the container increases the number of buckets and rebuilds the hash table as needed.
Rzeczywista kolejność elementów w kontrolowanej sekwencji zależy od funkcji mieszania, funkcji porównywania, kolejności wstawiania, współczynnika maksymalnego obciążenia i bieżącej liczby przedziałów.The actual order of elements in the controlled sequence depends on the hash function, the comparison function, the order of insertion, the maximum load factor, and the current number of buckets. Na ogół nie można przewidzieć kolejności elementów w kontrolowanej sekwencji.You cannot in general predict the order of elements in the controlled sequence. Można jednak zawsze mieć pewność, że dowolny podzbiór elementów, które mają równoważną kolejność, są obok siebie w kontrolowanej sekwencji.You can always be assured, however, that any subset of elements that have equivalent ordering are adjacent in the controlled sequence.
Obiekt przydziela i zwalnia magazyn dla sekwencji, która kontroluje przez przechowywany obiekt alokatora typu unordered_multiset:: allocator_type.The object allocates and frees storage for the sequence it controls through a stored allocator object of type unordered_multiset::allocator_type. Taki obiekt alokatora musi mieć ten sam interfejs zewnętrzny co obiekt typu allocator
.Such an allocator object must have the same external interface as an object of type allocator
. Należy zauważyć, że przechowywany obiekt alokatora nie jest kopiowany po przypisaniu obiektu kontenera.Note that the stored allocator object is not copied when the container object is assigned.
WymaganiaRequirements
Nagłówek:<unordered_set>Header: <unordered_set>
Przestrzeń nazw: stdNamespace: std
unordered_multiset:: allocator_typeunordered_multiset::allocator_type
Typ alokatora do zarządzania pamięcią.The type of an allocator for managing storage.
typedef Alloc allocator_type;
UwagiRemarks
Typ jest synonimem dla parametru szablonu Alloc
.The type is a synonym for the template parameter Alloc
.
PrzykładExample
// std__unordered_set__unordered_multiset_allocator_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
typedef std::allocator<std::pair<const char, int> > Myalloc;
int main()
{
Myset c1;
Myset::allocator_type al = c1.get_allocator();
std::cout << "al == std::allocator() is "
<< std::boolalpha << (al == Myalloc()) << std::endl;
return (0);
}
al == std::allocator() is true
unordered_multiset:: BEGINunordered_multiset::begin
Określa początek kontrolowanej sekwencji lub przedziału.Designates the beginning of the controlled sequence or a bucket.
iterator begin();
const_iterator begin() const;
local_iterator begin(size_type nbucket);
const_local_iterator begin(size_type nbucket) const;
ParametryParameters
nbucketnbucket
Numer zasobnika.The bucket number.
UwagiRemarks
Pierwsze dwie funkcje członkowskie zwracają iterator do przodu, który wskazuje na pierwszy element sekwencji (lub tuż poza końcem pustej sekwencji).The first two member functions return a forward iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Ostatnie dwie funkcje członkowskie zwracają iterator do przodu, który wskazuje na pierwszy element zasobnika nbucket (lub tuż poza końcem pustego zasobnika).The last two member functions return a forward iterator that points at the first element of bucket nbucket (or just beyond the end of an empty bucket).
PrzykładExample
// std__unordered_set__unordered_multiset_begin.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;
// inspect first two items "[c] [b]"
Myset::iterator it2 = c1.begin();
std::cout << "[" << *it2 << "] ";
++it2;
std::cout << "[" << *it2 << "] ";
std::cout << std::endl;
// inspect bucket containing 'a'
Myset::const_local_iterator lit = c1.begin(c1.bucket('a'));
std::cout << "[" << *lit << "] ";
return (0);
}
[c] [b] [a]
[c] [b]
[a]
unordered_multiset:: zasobnikunordered_multiset::bucket
Pobiera numer przedziału dla wartości klucza.Gets the bucket number for a key value.
size_type bucket(const Key& keyval) const;
ParametryParameters
keyvalkeyval
Wartość klucza do zamapowania.The key value to map.
UwagiRemarks
Funkcja członkowska zwraca numer zasobnika aktualnie odpowiadający wartości klucza keyval
.The member function returns the bucket number currently corresponding to the key value keyval
.
PrzykładExample
// std__unordered_set__unordered_multiset_bucket.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;
// display buckets for keys
Myset::size_type bs = c1.bucket('a');
std::cout << "bucket('a') == " << bs << std::endl;
std::cout << "bucket_size(" << bs << ") == " << c1.bucket_size(bs)
<< std::endl;
return (0);
}
[c] [b] [a]
bucket('a') == 7
bucket_size(7) == 1
unordered_multiset:: bucket_countunordered_multiset::bucket_count
Pobiera liczbę przedziałów.Gets the number of buckets.
size_type bucket_count() const;
UwagiRemarks
Funkcja członkowska zwraca bieżącą liczbę zasobników.The member function returns the current number of buckets.
PrzykładExample
// std__unordered_set__unordered_multiset_bucket_count.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;
// inspect current parameters
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// change max_load_factor and redisplay
c1.max_load_factor(0.10f);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// rehash and redisplay
c1.rehash(100);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1
bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1
unordered_multiset:: bucket_sizeunordered_multiset::bucket_size
Pobiera rozmiar zasobnikaGets the size of a bucket
size_type bucket_size(size_type nbucket) const;
ParametryParameters
nbucketnbucket
Numer zasobnika.The bucket number.
UwagiRemarks
Funkcja członkowska zwraca rozmiar zasobnika nbucket.The member functions returns the size of bucket number nbucket.
PrzykładExample
// std__unordered_set__unordered_multiset_bucket_size.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;
// display buckets for keys
Myset::size_type bs = c1.bucket('a');
std::cout << "bucket('a') == " << bs << std::endl;
std::cout << "bucket_size(" << bs << ") == " << c1.bucket_size(bs)
<< std::endl;
return (0);
}
[c] [b] [a]
bucket('a') == 7
bucket_size(7) == 1
unordered_multiset:: cbeginunordered_multiset::cbegin
Zwraca const
iterator, który odnosi się do pierwszego elementu w zakresie.Returns a const
iterator that addresses the first element in the range.
const_iterator cbegin() const;
Wartość zwracanaReturn Value
const
Iterator dostępu do przodu, który wskazuje na pierwszy element zakresu lub lokalizację tuż poza końcem pustego zakresu (dla pustego zakresu cbegin() == cend()
).A const
forward-access iterator that points at the first element of the range, or the location just beyond the end of an empty range (for an empty range, cbegin() == cend()
).
UwagiRemarks
Z wartością zwracaną cbegin
nie można modyfikować elementów w zakresie.With the return value of cbegin
, the elements in the range cannot be modified.
Można użyć tej funkcji elementu członkowskiego zamiast begin()
funkcji składowej, aby zagwarantować, że wartość zwracana to const_iterator
.You can use this member function in place of the begin()
member function to guarantee that the return value is const_iterator
. Zwykle jest używany w połączeniu z słowem kluczowym odejmowania autotype, jak pokazano w poniższym przykładzie.Typically, it's used in conjunction with the auto type deduction keyword, as shown in the following example. W tym przykładzie Rozważmy, Container
że jest to modyfikowalny const
kontener dowolnego rodzaju, który obsługuje begin()
i cbegin()
.In the example, consider Container
to be a modifiable (non- const
) container of any kind that supports begin()
and cbegin()
.
auto i1 = Container.begin();
// i1 is Container<T>::iterator
auto i2 = Container.cbegin();
// i2 is Container<T>::const_iterator
unordered_multiset:: cendunordered_multiset::cend
Zwraca const
iterator, który odnosi się do lokalizacji jedynie poza ostatnim elementem w zakresie.Returns a const
iterator that addresses the location just beyond the last element in a range.
const_iterator cend() const;
Wartość zwracanaReturn Value
const
Iterator dostępu do przodu, który wskazuje tuż poza końcem zakresu.A const
forward-access iterator that points just beyond the end of the range.
UwagiRemarks
cend
służy do sprawdzania, czy iterator przeszedł koniec zakresu.cend
is used to test whether an iterator has passed the end of its range.
Można użyć tej funkcji elementu członkowskiego zamiast end()
funkcji składowej, aby zagwarantować, że wartość zwracana to const_iterator
.You can use this member function in place of the end()
member function to guarantee that the return value is const_iterator
. Zwykle jest używany w połączeniu z słowem kluczowym odejmowania autotype, jak pokazano w poniższym przykładzie.Typically, it's used in conjunction with the auto type deduction keyword, as shown in the following example. W tym przykładzie Rozważmy, Container
że jest to modyfikowalny const
kontener dowolnego rodzaju, który obsługuje end()
i cend()
.In the example, consider Container
to be a modifiable (non- const
) container of any kind that supports end()
and cend()
.
auto i1 = Container.end();
// i1 is Container<T>::iterator
auto i2 = Container.cend();
// i2 is Container<T>::const_iterator
Nie można usunąć odwołania do wartości zwracanej przez cend
.The value returned by cend
should not be dereferenced.
unordered_multiset:: Clearunordered_multiset::clear
Usuwa wszystkie elementy.Removes all elements.
void clear();
UwagiRemarks
Funkcja członkowska wywołuje unordered_multiset:: Erase (
unordered_multiset:: BEGIN (),
unordered_multiset:: end ())
.The member function calls unordered_multiset::erase(
unordered_multiset::begin(),
unordered_multiset::end())
.
PrzykładExample
// std__unordered_set__unordered_multiset_clear.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;
// clear the container and reinspect
c1.clear();
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
std::cout << std::endl;
c1.insert('d');
c1.insert('e');
// display contents "[e] [d] "
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
return (0);
}
[c] [b] [a]
size == 0
empty() == true
[e] [d]
size == 2
empty() == false
unordered_multiset:: const_iteratorunordered_multiset::const_iterator
Typ iteratora stałego dla kontrolowanej sekwencji.The type of a constant iterator for the controlled sequence.
typedef T1 const_iterator;
UwagiRemarks
Typ opisuje obiekt, który może działać jako ciągły iterator do przodu dla kontrolowanej sekwencji.The type describes an object that can serve as a constant forward iterator for the controlled sequence. Jest on opisany tutaj jako synonim dla typu zdefiniowanego przez implementację T1
.It is described here as a synonym for the implementation-defined type T1
.
PrzykładExample
// std__unordered_set__unordered_multiset_const_iterator.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;
return (0);
}
[c] [b] [a]
unordered_multiset:: const_local_iteratorunordered_multiset::const_local_iterator
Typ iteratora stałego przedziału dla kontrolowanej sekwencji.The type of a constant bucket iterator for the controlled sequence.
typedef T5 const_local_iterator;
UwagiRemarks
Typ opisuje obiekt, który może obsłużyć ciągły iterator do przodu dla przedziału.The type describes an object that can serve as a constant forward iterator for a bucket. Jest on opisany tutaj jako synonim dla typu zdefiniowanego przez implementację T5
.It is described here as a synonym for the implementation-defined type T5
.
PrzykładExample
// std__unordered_set__unordered_multiset_const_local_iterator.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;
// inspect bucket containing 'a'
Myset::const_local_iterator lit = c1.begin(c1.bucket('a'));
std::cout << "[" << *lit << "] ";
return (0);
}
[c] [b] [a]
[a]
unordered_multiset:: const_pointerunordered_multiset::const_pointer
Typ stałego wskaźnika do elementu.The type of a constant pointer to an element.
typedef Alloc::const_pointer const_pointer;
UwagiRemarks
Typ opisuje obiekt, który może obsłużyć jako stały wskaźnik do elementu kontrolowanej sekwencji.The type describes an object that can serve as a constant pointer to an element of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_const_pointer.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::iterator it = c1.begin();
it != c1.end(); ++it)
{
Myset::const_pointer p = &*it;
std::cout << "[" << *p << "] ";
}
std::cout << std::endl;
return (0);
}
[c] [b] [a]
unordered_multiset:: const_referenceunordered_multiset::const_reference
Typ stałego odwołania do elementu.The type of a constant reference to an element.
typedef Alloc::const_reference const_reference;
UwagiRemarks
Typ opisuje obiekt, który może stanowić stałe odwołanie do elementu kontrolowanej sekwencji.The type describes an object that can serve as a constant reference to an element of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_const_reference.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::iterator it = c1.begin();
it != c1.end(); ++it)
{
Myset::const_reference ref = *it;
std::cout << "[" << ref << "] ";
}
std::cout << std::endl;
return (0);
}
[c] [b] [a]
unordered_multiset:: zawieraunordered_multiset::contains
Sprawdza, czy istnieje element z określonym kluczem w unordered_multiset
.Checks if there's an element with the specified key in the unordered_multiset
.
bool contains(const Key& key) const;
template<class K> bool contains(const K& key) const;
ParametryParameters
KK
Typ klucza.The type of the key.
głównychkey
Wartość klucza elementu do wyszukania.The element's key value to look for.
Wartość zwracanaReturn Value
true
Jeśli element znajduje się w kontenerze; false
w przeciwnym razie.true
if the element is found in the container; false
otherwise.
UwagiRemarks
contains()
Nowość w języku C++ 20.contains()
is new in C++20. Aby go użyć, określ /std: c + + Najnowsza opcja kompilatora.To use it, specify the /std:c++latest compiler option.
template<class K> bool contains(const K& key) const
występuje tylko w przypadku, gdy key_compare
jest przezroczysty.template<class K> bool contains(const K& key) const
only participates in overload resolution if key_compare
is transparent.
PrzykładExample
// Requires /std:c++latest
#include <unordered_set>
#include <iostream>
int main()
{
std::unordered_multiset<int> theUnorderedMultiset = { 1, 2, 3 };
std::cout << std::boolalpha; // so booleans show as 'true' or 'false'
std::cout << theUnorderedMultiset.contains(1) << '\n';
std::cout << theUnorderedMultiset.contains(4) << '\n';
return 0;
}
true
false
unordered_multiset:: Countunordered_multiset::count
Wyszukuje liczbę elementów pasujących do określonego klucza.Finds the number of elements matching a specified key.
size_type count(const Key& keyval) const;
ParametryParameters
keyvalkeyval
Wartość klucza do wyszukania.Key value to search for.
UwagiRemarks
Funkcja członkowska zwraca liczbę elementów w zakresie rozdzielonym przez unordered_multiset:: equal_range (keyval)
.The member function returns the number of elements in the range delimited by unordered_multiset::equal_range(keyval)
.
PrzykładExample
// std__unordered_set__unordered_multiset_count.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;
std::cout << "count('A') == " << c1.count('A') << std::endl;
std::cout << "count('b') == " << c1.count('b') << std::endl;
std::cout << "count('C') == " << c1.count('C') << std::endl;
return (0);
}
[c] [b] [a]
count('A') == 0
count('b') == 1
count('C') == 0
unordered_multiset::d ifference_typeunordered_multiset::difference_type
Typ odległości ze znakiem między dwoma elementami.The type of a signed distance between two elements.
typedef T3 difference_type;
UwagiRemarks
Typ Liczba całkowita ze znakiem opisuje obiekt, który może reprezentować różnicę między adresami wszystkich dwóch elementów w kontrolowanej sekwencji.The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. Jest on opisany tutaj jako synonim dla typu zdefiniowanego przez implementację T3
.It is described here as a synonym for the implementation-defined type T3
.
PrzykładExample
// std__unordered_set__unordered_multiset_difference_type.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;
// compute positive difference
Myset::difference_type diff = 0;
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
++diff;
std::cout << "end()-begin() == " << diff << std::endl;
// compute negative difference
diff = 0;
for (Myset::const_iterator it = c1.end();
it != c1.begin(); --it)
--diff;
std::cout << "begin()-end() == " << diff << std::endl;
return (0);
}
[c] [b] [a]
end()-begin() == 3
begin()-end() == -3
unordered_multiset:: emplaceunordered_multiset::emplace
Wstawia element skonstruowany w miejscu (nie są wykonywane żadne operacje kopiowania ani przenoszenia).Inserts an element constructed in place (no copy or move operations are performed).
template <class... Args>
iterator emplace(Args&&... args);
ParametryParameters
argumentówargs
Argumenty przekazywane do konstruowania elementu, który ma zostać wstawiony do unordered_multiset.The arguments forwarded to construct an element to be inserted into the unordered_multiset.
Wartość zwracanaReturn Value
Iterator do nowo wstawionego elementu.An iterator to the newly inserted element.
UwagiRemarks
Ta funkcja nie zawiera żadnych odwołań do elementów kontenera, ale może unieważnić wszystkie Iteratory do kontenera.No references to container elements are invalidated by this function, but it may invalidate all iterators to the container.
Podczas wstawiania, jeśli wyjątek jest zgłaszany, ale nie występuje w funkcji skrótu kontenera, kontener nie jest modyfikowany.During the insertion, if an exception is thrown but does not occur in the container's hash function, the container is not modified. Jeśli wyjątek jest zgłaszany w funkcji skrótu, wynik jest niezdefiniowany.If the exception is thrown in the hash function, the result is undefined.
Aby zapoznać się z przykładem kodu, zobacz zestaw wielokrotny:: emplace.For a code example, see multiset::emplace.
unordered_multiset:: emplace_hintunordered_multiset::emplace_hint
Wstawia element skonstruowany w miejscu (nie są wykonywane żadne operacje kopiowania ani przenoszenia) z wskazówką dotyczącą położenia.Inserts an element constructed in place (no copy or move operations are performed), with a placement hint.
template <class... Args>
iterator emplace_hint(
const_iterator where,
Args&&... args);
ParametryParameters
argumentówargs
Argumenty przekazywane do konstruowania elementu, który ma zostać wstawiony do unordered_multiset.The arguments forwarded to construct an element to be inserted into the unordered_multiset.
miejscuwhere
Wskazówka dotycząca miejsca, w którym rozpoczyna się wyszukiwanie poprawnego punktu wstawiania.A hint regarding the place to start searching for the correct point of insertion.
Wartość zwracanaReturn Value
Iterator do nowo wstawionego elementu.An iterator to the newly inserted element.
UwagiRemarks
Ta funkcja nie zawiera żadnych odwołań do elementów kontenera, ale może unieważnić wszystkie Iteratory do kontenera.No references to container elements are invalidated by this function, but it may invalidate all iterators to the container.
Podczas wstawiania, jeśli wyjątek jest zgłaszany, ale nie występuje w funkcji skrótu kontenera, kontener nie jest modyfikowany.During the insertion, if an exception is thrown but does not occur in the container's hash function, the container is not modified. Jeśli wyjątek jest zgłaszany w funkcji skrótu, wynik jest niezdefiniowany.If the exception is thrown in the hash function, the result is undefined.
Aby zapoznać się z przykładem kodu, zobacz set:: emplace_hint.For a code example, see set::emplace_hint.
unordered_multiset:: Emptyunordered_multiset::empty
Sprawdza, czy nie ma żadnych elementów.Tests whether no elements are present.
bool empty() const;
UwagiRemarks
Funkcja członkowska zwraca wartość true dla pustej kontrolowanej sekwencji.The member function returns true for an empty controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_empty.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;
// clear the container and reinspect
c1.clear();
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
std::cout << std::endl;
c1.insert('d');
c1.insert('e');
// display contents "[e] [d]"
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
return (0);
}
[c] [b] [a]
size == 0
empty() == true
[e] [d]
size == 2
empty() == false
unordered_multiset:: endunordered_multiset::end
Określa koniec kontrolowanej sekwencji.Designates the end of the controlled sequence.
iterator end();
const_iterator end() const;
local_iterator end(size_type nbucket);
const_local_iterator end(size_type nbucket) const;
ParametryParameters
nbucketnbucket
Numer zasobnika.The bucket number.
UwagiRemarks
Pierwsze dwie funkcje członkowskie zwracają iterator do przodu, który wskazuje tuż poza końcem sekwencji.The first two member functions return a forward iterator that points just beyond the end of the sequence. Ostatnie dwie funkcje członkowskie zwracają iterator do przodu, który wskazuje tuż poza końcem zasobnika nbucket.The last two member functions return a forward iterator that points just beyond the end of bucket nbucket.
PrzykładExample
// std__unordered_set__unordered_multiset_end.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;
// inspect last two items "[a] [b]"
Myset::iterator it2 = c1.end();
--it2;
std::cout << "[" << *it2 << "] ";
--it2;
std::cout << "[" << *it2 << "] ";
std::cout << std::endl;
// inspect bucket containing 'a'
Myset::const_local_iterator lit = c1.end(c1.bucket('a'));
--lit;
std::cout << "[" << *lit << "] ";
return (0);
}
[c] [b] [a]
[a] [b]
[a]
unordered_multiset:: equal_rangeunordered_multiset::equal_range
Wyszukuje zakres, który odpowiada określonemu kluczowi.Finds range that matches a specified key.
std::pair<iterator, iterator>
equal_range(const Key& keyval);
std::pair<const_iterator, const_iterator>
equal_range(const Key& keyval) const;
ParametryParameters
keyvalkeyval
Wartość klucza do wyszukania.Key value to search for.
UwagiRemarks
Funkcja członkowska zwraca parę iteratorów X
, które [X.first, X.second)
ograniczają tylko te elementy kontrolowanej sekwencji, które mają równoważne porządkowanie z keyval.The member function returns a pair of iterators X
such that [X.first, X.second)
delimits just those elements of the controlled sequence that have equivalent ordering with keyval. Jeśli takie elementy nie istnieją, oba Iteratory są end()
.If no such elements exist, both iterators are end()
.
PrzykładExample
// std__unordered_set__unordered_multiset_equal_range.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;
// display results of failed search
std::pair<Myset::iterator, Myset::iterator> pair1 =
c1.equal_range('x');
std::cout << "equal_range('x'):";
for (; pair1.first != pair1.second; ++pair1.first)
std::cout << "[" << *pair1.first << "] ";
std::cout << std::endl;
// display results of successful search
pair1 = c1.equal_range('b');
std::cout << "equal_range('b'):";
for (; pair1.first != pair1.second; ++pair1.first)
std::cout << "[" << *pair1.first << "] ";
std::cout << std::endl;
return (0);
}
[c] [b] [a]
equal_range('x'):
equal_range('b'): [b]
unordered_multiset:: Eraseunordered_multiset::erase
Usuwa element lub zakres elementów w unordered_multiset z określonych pozycji lub usuwa elementy, które pasują do określonego klucza.Removes an element or a range of elements in a unordered_multiset from specified positions or removes elements that match a specified key.
iterator erase(
const_iterator Where);
iterator erase(
const_iterator First,
const_iterator Last);
size_type erase(
const key_type& Key);
ParametryParameters
MiejscuWhere
Pozycja elementu, który ma zostać usunięty.Position of the element to be removed.
PierwszegoFirst
Pozycja pierwszego elementu, który ma zostać usunięty.Position of the first element to be removed.
OstatniegoLast
Umieść tuż poza ostatnim elementem, który ma zostać usunięty.Position just beyond the last element to be removed.
GłównychKey
Wartość klucza elementów do usunięcia.The key value of the elements to be removed.
Wartość zwracanaReturn Value
W przypadku pierwszych dwóch funkcji składowych iterator dwukierunkowy, który wyznacza pierwszy element, który jest poza wszystkimi elementami usuniętymi lub element, który jest końcem unordered_multiset, jeśli taki element nie istnieje.For the first two member functions, a bidirectional iterator that designates the first element remaining beyond any elements removed, or an element that is the end of the unordered_multiset if no such element exists.
Dla trzeciej funkcji składowej zwraca liczbę elementów usuniętych z unordered_multiset.For the third member function, returns the number of elements that have been removed from the unordered_multiset.
UwagiRemarks
Aby zapoznać się z przykładem kodu, zobacz set:: Erase.For a code example, see set::erase.
unordered_multiset:: findunordered_multiset::find
Wyszukuje element, który odpowiada określonemu kluczowi.Finds an element that matches a specified key.
const_iterator find(const Key& keyval) const;
ParametryParameters
keyvalkeyval
Wartość klucza do wyszukania.Key value to search for.
UwagiRemarks
Funkcja członkowska zwraca unordered_multiset:: equal_range (keyval).first
.The member function returns unordered_multiset::equal_range(keyval).first
.
PrzykładExample
// std__unordered_set__unordered_multiset_find.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;
// try to find and fail
std::cout << "find('A') == "
<< std::boolalpha << (c1.find('A') != c1.end()) << std::endl;
// try to find and succeed
Myset::iterator it = c1.find('b');
std::cout << "find('b') == "
<< std::boolalpha << (it != c1.end())
<< ": [" << *it << "] " << std::endl;
return (0);
}
[c] [b] [a]
find('A') == false
find('b') == true: [b]
unordered_multiset:: get_allocatorunordered_multiset::get_allocator
Pobiera przechowywany obiekt alokatora.Gets the stored allocator object.
Alloc get_allocator() const;
UwagiRemarks
Funkcja członkowska zwraca przechowywany obiekt alokatora.The member function returns the stored allocator object.
PrzykładExample
// std__unordered_set__unordered_multiset_get_allocator.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
typedef std::allocator<std::pair<const char, int> > Myalloc;
int main()
{
Myset c1;
Myset::allocator_type al = c1.get_allocator();
std::cout << "al == std::allocator() is "
<< std::boolalpha << (al == Myalloc()) << std::endl;
return (0);
}
al == std::allocator() is true
unordered_multiset:: hash_functionunordered_multiset::hash_function
Pobiera przechowywany obiekt funkcji mieszania.Gets the stored hash function object.
Hash hash_function() const;
UwagiRemarks
Funkcja członkowska zwraca przechowywany obiekt funkcji skrótu.The member function returns the stored hash function object.
PrzykładExample
// std__unordered_set__unordered_multiset_hash_function.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
Myset::hasher hfn = c1.hash_function();
std::cout << "hfn('a') == " << hfn('a') << std::endl;
std::cout << "hfn('b') == " << hfn('b') << std::endl;
return (0);
}
hfn('a') == 1630279
hfn('b') == 1647086
unordered_multiset:: Hasherunordered_multiset::hasher
Typ funkcji mieszania.The type of the hash function.
typedef Hash hasher;
UwagiRemarks
Typ jest synonimem dla parametru szablonu Hash
.The type is a synonym for the template parameter Hash
.
PrzykładExample
// std__unordered_set__unordered_multiset_hasher.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
Myset::hasher hfn = c1.hash_function();
std::cout << "hfn('a') == " << hfn('a') << std::endl;
std::cout << "hfn('b') == " << hfn('b') << std::endl;
return (0);
}
hfn('a') == 1630279
hfn('b') == 1647086
unordered_multiset:: INSERTunordered_multiset::insert
Wstawia element lub zakres elementów do unordered_multiset.Inserts an element or a range of elements into an unordered_multiset.
// (1) single element
pair<iterator, bool> insert(
const value_type& Val);
// (2) single element, perfect forwarded
template <class ValTy>
pair<iterator, bool>
insert(
ValTy&& Val);
// (3) single element with hint
iterator insert(
const_iterator Where,
const value_type& Val);
// (4) single element, perfect forwarded, with hint
template <class ValTy>
iterator insert(
const_iterator Where,
ValTy&& Val);
// (5) range
template <class InputIterator>
void insert(
InputIterator First,
InputIterator Last);
// (6) initializer list
void insert(
initializer_list<value_type>
IList);
ParametryParameters
UżyteVal
Wartość elementu, który ma zostać wstawiony do unordered_multiset.The value of an element to be inserted into the unordered_multiset.
MiejscuWhere
Miejsce, w którym rozpocznie się wyszukiwanie poprawnego punktu wstawiania.The place to start searching for the correct point of insertion.
ValTyValTy
Parametr szablonu, który określa typ argumentu, który unordered_multiset może używać do konstruowania elementu value_typei idealny do przesyłania dalej jako argumentu .Template parameter that specifies the argument type that the unordered_multiset can use to construct an element of value_type, and perfect-forwards Val as an argument.
PierwszegoFirst
Pozycja pierwszego elementu, który ma zostać skopiowany.The position of the first element to be copied.
OstatniegoLast
Pozycja tuż poza ostatnim elementem, który ma zostać skopiowany.The position just beyond the last element to be copied.
InputIteratorInputIterator
Argument funkcji szablonu, który spełnia wymagania iteratora danych wejściowych , który wskazuje elementy typu, które mogą być używane do konstruowania obiektów value_type .Template function argument that meets the requirements of an input iterator that points to elements of a type that can be used to construct value_type objects.
IListIList
Initializer_list , z którego mają zostać skopiowane elementy.The initializer_list from which to copy the elements.
Wartość zwracanaReturn Value
Funkcje składowe pojedynczego elementu, (1) i (2) zwracają iterator do pozycji, w której nowy element został wstawiony do unordered_multiset.The single-element-insert member functions, (1) and (2), return an iterator to the position where the new element was inserted into the unordered_multiset.
Jednoelementowa funkcja członkowska, (3) i (4) zwraca iterator, który wskazuje na miejsce, w którym nowy element został wstawiony do unordered_multiset.The single-element-with-hint member functions, (3) and (4), return an iterator that points to the position where the new element was inserted into the unordered_multiset.
UwagiRemarks
Ta funkcja nie sprawdza wskaźników ani odwołań, ale może unieważnić wszystkie Iteratory do kontenera.No pointers or references are invalidated by this function, but it may invalidate all iterators to the container.
Podczas wstawiania tylko jednego elementu, jeśli wyjątek jest zgłaszany, ale nie występuje w funkcji skrótu kontenera, stan kontenera nie jest modyfikowany.During the insertion of just one element, if an exception is thrown but does not occur in the container's hash function, the container's state is not modified. Jeśli wyjątek jest zgłaszany w funkcji skrótu, wynik jest niezdefiniowany.If the exception is thrown in the hash function, the result is undefined. Podczas wstawiania wielu elementów, jeśli wyjątek jest zgłaszany, kontener pozostaje w nieokreślonym, ale prawidłowym stanie.During the insertion of multiple elements, if an exception is thrown, the container is left in an unspecified but valid state.
Value_type kontenera jest elementem TypeDef, który należy do kontenera, a dla zestawu, unordered_multiset<V>::value_type
jest typ const V
.The value_type of a container is a typedef that belongs to the container, and, for set, unordered_multiset<V>::value_type
is type const V
.
Funkcja elementu członkowskiego zakresu (5) wstawia sekwencję wartości elementów do unordered_multiset, która odnosi się do każdego elementu, którego dotyczy iterator w zakresie [First, Last)
; w związku z tym ostatni nie zostanie wstawiony.The range member function (5) inserts the sequence of element values into an unordered_multiset that corresponds to each element addressed by an iterator in the range [First, Last)
; therefore, Last does not get inserted. Funkcja elementu członkowskiego kontenera end()
odwołuje się do pozycji tuż po ostatnim elemencie w kontenerze — na przykład, instrukcja m.insert(v.begin(), v.end());
wstawia wszystkie elementy v
do m
.The container member function end()
refers to the position just after the last element in the container—for example, the statement m.insert(v.begin(), v.end());
inserts all elements of v
into m
.
Funkcja członkowska listy inicjatorów (6) używa initializer_list do kopiowania elementów do unordered_multiset.The initializer list member function (6) uses an initializer_list to copy elements into the unordered_multiset.
Do wstawienia elementu skonstruowanego w miejscu — to znaczy, że nie są wykonywane żadne operacje kopiowania ani przenoszenia — zobacz unordered_multiset:: emplace i unordered_multiset:: emplace_hint.For insertion of an element constructed in place—that is, no copy or move operations are performed—see unordered_multiset::emplace and unordered_multiset::emplace_hint.
Aby zapoznać się z przykładem kodu, zobacz zestaw wielokrotny:: INSERT.For a code example, see multiset::insert.
unordered_multiset:: iteratorunordered_multiset::iterator
Typ, który zapewnia ciągły iterator do przodu , który może odczytywać elementy w unordered_multiset.A type that provides a constant forward iterator that can read elements in an unordered_multiset.
typedef implementation-defined iterator;
PrzykładExample
Zapoznaj się z przykładem początku, aby zapoznać się z przykładem sposobu deklarowania iteratorai korzystania z niego.See the example for begin for an example of how to declare and use an iterator.
unordered_multiset:: key_equnordered_multiset::key_eq
Pobiera przechowywany obiekt funkcji porównywania.Gets the stored comparison function object.
Pred key_eq() const;
UwagiRemarks
Funkcja członkowska zwraca przechowywany obiekt funkcji porównywania.The member function returns the stored comparison function object.
PrzykładExample
// std__unordered_set__unordered_multiset_key_eq.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
Myset::key_equal cmpfn = c1.key_eq();
std::cout << "cmpfn('a', 'a') == "
<< std::boolalpha << cmpfn('a', 'a') << std::endl;
std::cout << "cmpfn('a', 'b') == "
<< std::boolalpha << cmpfn('a', 'b') << std::endl;
return (0);
}
cmpfn('a', 'a') == true
cmpfn('a', 'b') == false
unordered_multiset:: key_equalunordered_multiset::key_equal
Typ funkcji porównywania.The type of the comparison function.
typedef Pred key_equal;
UwagiRemarks
Typ jest synonimem dla parametru szablonu Pred
.The type is a synonym for the template parameter Pred
.
PrzykładExample
// std__unordered_set__unordered_multiset_key_equal.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
Myset::key_equal cmpfn = c1.key_eq();
std::cout << "cmpfn('a', 'a') == "
<< std::boolalpha << cmpfn('a', 'a') << std::endl;
std::cout << "cmpfn('a', 'b') == "
<< std::boolalpha << cmpfn('a', 'b') << std::endl;
return (0);
}
cmpfn('a', 'a') == true
cmpfn('a', 'b') == false
unordered_multiset:: key_typeunordered_multiset::key_type
Typ klucza sortowania.The type of an ordering key.
typedef Key key_type;
UwagiRemarks
Typ jest synonimem dla parametru szablonu Key
.The type is a synonym for the template parameter Key
.
PrzykładExample
// std__unordered_set__unordered_multiset_key_type.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;
// add a value and reinspect
Myset::key_type key = 'd';
Myset::value_type val = key;
c1.insert(val);
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
return (0);
}
[c] [b] [a]
[d] [c] [b] [a]
unordered_multiset:: load_factorunordered_multiset::load_factor
Oblicza średnią liczbę elementów na przedział.Counts the average elements per bucket.
float load_factor() const;
UwagiRemarks
Funkcja członkowska zwraca (float)
unordered_multiset:: size () / (float)
unordered_multiset:: bucket_count ()
, średnią liczbę elementów na przedział.The member function returns (float)
unordered_multiset::size() / (float)
unordered_multiset::bucket_count()
, the average number of elements per bucket.
PrzykładExample
// std__unordered_set__unordered_multiset_load_factor.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;
// inspect current parameters
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// change max_load_factor and redisplay
c1.max_load_factor(0.10f);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// rehash and redisplay
c1.rehash(100);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
return (0);
}
unordered_multiset:: local_iteratorunordered_multiset::local_iterator
Typ iteratora zasobnika.The type of a bucket iterator.
typedef T4 local_iterator;
UwagiRemarks
Typ opisuje obiekt, który może obsłużyć iterator do przodu dla przedziału.The type describes an object that can serve as a forward iterator for a bucket. Jest on opisany tutaj jako synonim dla typu zdefiniowanego przez implementację T4
.It is described here as a synonym for the implementation-defined type T4
.
PrzykładExample
// std__unordered_set__unordered_multiset_local_iterator.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;
// inspect bucket containing 'a'
Myset::local_iterator lit = c1.begin(c1.bucket('a'));
std::cout << "[" << *lit << "] ";
return (0);
}
[c] [b] [a]
[a]
unordered_multiset:: max_bucket_countunordered_multiset::max_bucket_count
Pobiera maksymalną liczbę przedziałów.Gets the maximum number of buckets.
size_type max_bucket_count() const;
UwagiRemarks
Funkcja członkowska zwraca maksymalną dozwoloną liczbę zasobników.The member function returns the maximum number of buckets currently permitted.
PrzykładExample
// std__unordered_set__unordered_multiset_max_bucket_count.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;
// inspect current parameters
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// change max_load_factor and redisplay
c1.max_load_factor(0.10f);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// rehash and redisplay
c1.rehash(100);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1
bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1
unordered_multiset:: max_load_factorunordered_multiset::max_load_factor
Pobiera lub ustawia maksymalną liczbę elementów na przedział.Gets or sets the maximum elements per bucket.
float max_load_factor() const;
void max_load_factor(float factor);
ParametryParameters
1Ufactor
Nowy maksymalny współczynnik obciążenia.The new maximum load factor.
UwagiRemarks
Pierwsza funkcja członkowska zwraca przechowywany maksymalny współczynnik obciążenia.The first member function returns the stored maximum load factor. Druga funkcja członkowska zastępuje zachowaną wartość maksymalnego obciążenia czynnikem.The second member function replaces the stored maximum load factor with factor.
PrzykładExample
// std__unordered_set__unordered_multiset_max_load_factor.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;
// inspect current parameters
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// change max_load_factor and redisplay
c1.max_load_factor(0.10f);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
// rehash and redisplay
c1.rehash(100);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_bucket_count() == "
<< c1.max_bucket_count() << std::endl;
std::cout << "max_load_factor() == "
<< c1.max_load_factor() << std::endl;
std::cout << std::endl;
return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 4
bucket_count() == 8
load_factor() == 0.375
max_bucket_count() == 8
max_load_factor() == 0.1
bucket_count() == 128
load_factor() == 0.0234375
max_bucket_count() == 128
max_load_factor() == 0.1
unordered_multiset:: max_sizeunordered_multiset::max_size
Pobiera maksymalny rozmiar kontrolowanej sekwencji.Gets the maximum size of the controlled sequence.
size_type max_size() const;
UwagiRemarks
Funkcja członkowska zwraca długość najdłuższej sekwencji, którą obiekt może kontrolować.The member function returns the length of the longest sequence that the object can control.
PrzykładExample
// std__unordered_set__unordered_multiset_max_size.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
std::cout << "max_size() == " << c1.max_size() << std::endl;
return (0);
}
max_size() == 4294967295
unordered_multiset:: operator =unordered_multiset::operator=
Kopiuje tabelę mieszania.Copies a hash table.
unordered_multiset& operator=(const unordered_multiset& right);
unordered_multiset& operator=(unordered_multiset&& right);
ParametryParameters
Kliknijright
Unordered_multiset kopiowana do programu unordered_multiset
.The unordered_multiset being copied into the unordered_multiset
.
UwagiRemarks
Po wymazaniu wszelkich istniejących elementów w programie unordered_multiset
, operator=
kopiuje lub przenosi zawartość bezpośrednio do unordered_multiset
.After erasing any existing elements in an unordered_multiset
, operator=
either copies or moves the contents of right into the unordered_multiset
.
PrzykładExample
// unordered_multiset_operator_as.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
int main( )
{
using namespace std;
unordered_multiset<int> v1, v2, v3;
unordered_multiset<int>::iterator iter;
v1.insert(10);
cout << "v1 = " ;
for (iter = v1.begin(); iter != v1.end(); iter++)
cout << *iter << " ";
cout << endl;
v2 = v1;
cout << "v2 = ";
for (iter = v2.begin(); iter != v2.end(); iter++)
cout << *iter << " ";
cout << endl;
// move v1 into v2
v2.clear();
v2 = move(v1);
cout << "v2 = ";
for (iter = v2.begin(); iter != v2.end(); iter++)
cout << *iter << " ";
cout << endl;
}
unordered_multiset::p ointerunordered_multiset::pointer
Typ wskaźnika do elementu.The type of a pointer to an element.
typedef Alloc::pointer pointer;
UwagiRemarks
Typ opisuje obiekt, który może obsłużyć jako wskaźnik do elementu kontrolowanej sekwencji.The type describes an object that can serve as a pointer to an element of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_pointer.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::iterator it = c1.begin();
it != c1.end(); ++it)
{
Myset::key_type key = *it;
Myset::pointer p = &key;
std::cout << "[" << *p << "] ";
}
std::cout << std::endl;
return (0);
}
[c] [b] [a]
unordered_multiset:: Referenceunordered_multiset::reference
Typ odwołania do elementu.The type of a reference to an element.
typedef Alloc::reference reference;
UwagiRemarks
Typ opisuje obiekt, który może obsłużyć jako odwołanie do elementu kontrolowanej sekwencji.The type describes an object that can serve as a reference to an element of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_reference.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::iterator it = c1.begin();
it != c1.end(); ++it)
{
Myset::key_type key = *it;
Myset::reference ref = key;
std::cout << "[" << ref << "] ";
}
std::cout << std::endl;
return (0);
}
[c] [b] [a]
unordered_multiset:: rehashunordered_multiset::rehash
Przebudowuje tabelę mieszania.Rebuilds the hash table.
void rehash(size_type nbuckets);
ParametryParameters
nbucketsnbuckets
Żądana liczba zasobników.The requested number of buckets.
UwagiRemarks
Funkcja członkowska zmienia liczbę przedziałów na co najmniej nbuckets i ponownie kompiluje tabelę skrótów zgodnie z wymaganiami.The member function alters the number of buckets to be at least nbuckets and rebuilds the hash table as needed.
PrzykładExample
// std__unordered_set__unordered_multiset_rehash.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;
// inspect current parameters
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;
std::cout << std::endl;
// change max_load_factor and redisplay
c1.max_load_factor(0.10f);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;
std::cout << std::endl;
// rehash and redisplay
c1.rehash(100);
std::cout << "bucket_count() == " << c1.bucket_count() << std::endl;
std::cout << "load_factor() == " << c1.load_factor() << std::endl;
std::cout << "max_load_factor() == " << c1.max_load_factor() << std::endl;
return (0);
}
[c] [b] [a]
bucket_count() == 8
load_factor() == 0.375
max_load_factor() == 4
bucket_count() == 8
load_factor() == 0.375
max_load_factor() == 0.1
bucket_count() == 128
load_factor() == 0.0234375
max_load_factor() == 0.1
unordered_multiset:: sizeunordered_multiset::size
Liczy liczbę elementów.Counts the number of elements.
size_type size() const;
UwagiRemarks
Funkcja członkowska zwraca długość kontrolowanej sekwencji.The member function returns the length of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_size.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;
// clear the container and reinspect
c1.clear();
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
std::cout << std::endl;
c1.insert('d');
c1.insert('e');
// display contents "[e] [d]"
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
std::cout << "size == " << c1.size() << std::endl;
std::cout << "empty() == " << std::boolalpha << c1.empty() << std::endl;
return (0);
}
[c] [b] [a]
size == 0
empty() == true
[e] [d]
size == 2
empty() == false
unordered_multiset:: size_typeunordered_multiset::size_type
Typ odległości bez znaku między dwoma elementami.The type of an unsigned distance between two elements.
typedef T2 size_type;
UwagiRemarks
Typ liczby całkowitej bez znaku opisuje obiekt, który może reprezentować długość dowolnej kontrolowanej sekwencji.The unsigned integer type describes an object that can represent the length of any controlled sequence. Jest on opisany tutaj jako synonim dla typu zdefiniowanego przez implementację T2
.It is described here as a synonym for the implementation-defined type T2
.
PrzykładExample
// std__unordered_set__unordered_multiset_size_type.cpp
// compile with: /EHsc
#include <unordered_set>
#include <iostream>
typedef std::unordered_multiset<char> Myset;
int main()
{
Myset c1;
Myset::size_type sz = c1.size();
std::cout << "size == " << sz << std::endl;
return (0);
}
size == 0
unordered_multiset:: swapunordered_multiset::swap
Zamienia zawartości dwóch kontenerów.Swaps the contents of two containers.
void swap(unordered_multiset& right);
ParametryParameters
Kliknijright
Kontener, w którym ma zostać zamieniony.The container to swap with.
UwagiRemarks
Funkcja członkowska zamienia kontrolowane sekwencje między *this
i po prawej.The member function swaps the controlled sequences between *this
and right. Jeśli unordered_multiset:: get_allocator () == right.get_allocator()
, robi to w stałym czasie, zgłasza wyjątek tylko w wyniku kopiowania obiektu składowanych cech typu Tr
i unieważnia odwołania, wskaźniki lub Iteratory, które wyznaczają elementy w dwóch kontrolowanej sekwencji.If unordered_multiset::get_allocator() == right.get_allocator()
, it does so in constant time, it throws an exception only as a result of copying the stored traits object of type Tr
, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. W przeciwnym razie wykonuje wiele przypisań elementów i wywołań konstruktora proporcjonalnie do liczby elementów w dwóch kontrolowanej sekwencji.Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
PrzykładExample
// std__unordered_set__unordered_multiset_swap.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;
c2.insert('d');
c2.insert('e');
c2.insert('f');
c1.swap(c2);
// display contents "[f] [e] [d]"
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
swap(c1, c2);
// display contents "[c] [b] [a]"
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
return (0);
}
[c] [b] [a]
[f] [e] [d]
[c] [b] [a]
unordered_multiset:: unordered_multisetunordered_multiset::unordered_multiset
Konstruuje obiekt kontenera.Constructs a container object.
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());
ParametryParameters
InputIteratorInputIterator
Typ iteratora.The iterator type.
WspAl
Obiekt alokatora, który ma być przechowywany.The allocator object to store.
PrzepisówComp
Obiekt funkcji porównywania, który ma być przechowywany.The comparison function object to store.
SkrótuHash
Obiekt funkcji mieszania, który ma być przechowywany.The hash function object to store.
Bucket_countBucket_count
Minimalna liczba przedziałów.The minimum number of buckets.
KliknijRight
Kontener, który ma być skopiowany.The container to copy.
IListIList
Initializer_list, z którego ma zostać skopiowana.The initializer_list from which to copy.
UwagiRemarks
Pierwszy Konstruktor określa kopię sekwencji kontrolowanej przez prawo.The first constructor specifies a copy of the sequence controlled by Right. Drugi konstruktor określa pustą kontrolowaną sekwencję.The second constructor specifies an empty controlled sequence. Trzeci Konstruktor wstawia sekwencję wartości elementów [First, Last)
.The third constructor inserts the sequence of element values [First, Last)
. Czwarty Konstruktor określa kopię sekwencji, przenosząc prawo.The fourth constructor specifies a copy of the sequence by moving Right.
Wszystkie konstruktory również inicjują kilka przechowywanych wartości.All constructors also initialize several stored values. W przypadku konstruktora kopiującego wartości są uzyskiwane z prawej strony.For the copy constructor, the values are obtained from Right. W przeciwnym razie:Otherwise:
Minimalna liczba przedziałów jest argumentem Bucket_count, jeśli istnieje; w przeciwnym razie jest to wartość domyślna opisana tutaj jako wartość zdefiniowana przez implementację N0
.The minimum number of buckets is the argument Bucket_count, if present; otherwise it is a default value described here as the implementation-defined value N0
.
Obiekt funkcji mieszania jest wartością skrótuargumentu (jeśli istnieje); w przeciwnym razie Hash()
.The hash function object is the argument Hash, if present; otherwise it is Hash()
.
Obiekt funkcji porównywania jest argumentem COMP, jeśli jest obecny; w przeciwnym razie Comp()
.The comparison function object is the argument Comp, if present; otherwise it is Comp()
.
Obiekt alokatora jest argumentem Al, jeśli jest obecny; w przeciwnym razie jest to Alloc()
.The allocator object is the argument Al, if present; otherwise, it is Alloc()
.
unordered_multiset:: value_typeunordered_multiset::value_type
Typ elementu.The type of an element.
typedef Key value_type;
UwagiRemarks
Typ opisuje element kontrolowanej sekwencji.The type describes an element of the controlled sequence.
PrzykładExample
// std__unordered_set__unordered_multiset_value_type.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;
// add a value and reinspect
Myset::key_type key = 'd';
Myset::value_type val = key;
c1.insert(val);
for (Myset::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << "[" << *it << "] ";
std::cout << std::endl;
return (0);
}
[c] [b] [a]
[d] [c] [b] [a]
Zobacz teżSee also
<unordered_set><unordered_set>
OpakowaniaContainers
Bezpieczeństwo wątku w standardowej bibliotece języka C++Thread Safety in the C++ Standard Library
Dokumentacja standardowej biblioteki języka C++C++ Standard Library Reference