A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/unordered_multiset below:

class template

<unordered_set>

std::unordered_multiset
template < class Key,                         // unordered_multiset::key_type/value_type           class Hash = hash<Key>,            // unordered_multiset::hasher           class Pred = equal_to<Key>,        // unordered_multiset::key_equal           class Alloc = allocator<Key>       // unordered_multiset::allocator_type           > class unordered_multiset;

Unordered Multiset

Unordered multisets are containers that store elements in no particular order, allowing fast retrieval of individual elements based on their value, much like unordered_set containers, but allowing different elements to have equivalent values.

In an unordered_multiset, the value of an element is at the same time its key, used to identify it. Keys are immutable, therefore, the elements in an unordered_multiset cannot be modified once in the container - they can be inserted and removed, though.

Internally, the elements in the unordered_multiset are not sorted in any particular, but organized into buckets depending on their hash values to allow for fast access to individual elements directly by their values (with a constant average time complexity on average).

Elements with equivalent values are grouped together in the same bucket and in such a way that an iterator (see equal_range) can iterate through all of them.

Iterators in the container are at least forward iterators.

Notice that this container is not defined in its own header, but shares header <unordered_set> with unordered_set.



Container properties
Associative
Elements in associative containers are referenced by their key and not by their absolute position in the container.
Unordered
Unordered containers organize their elements using hash tables that allow for fast access to elements by their key.
Set
The value of an element is also the key used to identify it.
Multiple equivalent keys
The container can hold multiple elements with equivalent keys.
Allocator-aware
The container uses an allocator object to dynamically handle its storage needs.

Template parameters
Key
Type of the elements. Each element in an unordered_multiset is also identified by this value.
Aliased as member types unordered_multiset::key_type and unordered_multiset::value_type.
Hash
A unary function object type that takes an object of the same type as the elements as argument and returns a unique value of type size_t based on it. This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example). This defaults to hash<Key>, which returns a hash value with a probability of collision approaching 1.0/std::numeric_limits<size_t>::max().
The unordered_multiset object uses the hash values returned by this function to organize its elements internally, speeding up the process of locating individual elements.
Aliased as member type unordered_multiset::hasher.
Pred
A binary predicate that takes two arguments of the same type as the elements and returns a bool. The expression pred(a,b), where pred is an object of this type and a and b are key values, shall return true if a is to be considered equivalent to b. This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example). This defaults to equal_to<Key>, which returns the same as applying the equal-to operator (a==b).
The unordered_multiset object uses this expression to determine whether two element keys are equivalent. This container supports multiple elements with equivalent keys.
Aliased as member type unordered_multiset::key_equal.
Alloc
Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type unordered_multiset::allocator_type.

In the reference for the unordered_multiset member functions, these same names (Key, Hash, Pred and Alloc) are assumed for the template parameters.

Member types The following aliases are member types of unordered_multiset. They are widely used as parameter and return types by member functions:

member type definition notes key_type the first template parameter (Key) value_type the first template parameter (Key) The same as key_type hasher the second template parameter (Hash) defaults to: hash<key_type> key_equal the third template parameter (Pred) defaults to: equal_to<key_type> allocator_type the fourth template parameter (Alloc) defaults to: allocator<value_type> reference Alloc::reference const_reference Alloc::const_reference pointer Alloc::pointer for the default allocator: value_type* const_pointer Alloc::const_pointer for the default allocator: const value_type* iterator a forward iterator to const value_type * convertible to const_iterator const_iterator a forward iterator to const value_type * local_iterator a forward iterator to const value_type * convertible to const_local_iterator const_local_iterator a forward iterator to const value_type * size_type an unsigned integral type usually the same as size_t difference_type a signed integral type usually the same as ptrdiff_t member type definition notes key_type the first template parameter (Key) value_type the first template parameter (Key) The same as key_type hasher the second template parameter (Hash) defaults to: hash<key_type> key_equal the third template parameter (Pred) defaults to: equal_to<key_type> allocator_type the fourth template parameter (Alloc) defaults to: allocator<value_type> reference value_type& const_reference const value_type& pointer allocator_traits<Alloc>::pointer for the default allocator: value_type* const_pointer allocator_traits<Alloc>::const_pointer for the default allocator: const value_type* iterator a forward iterator to const value_type * convertible to const_iterator const_iterator a forward iterator to const value_type * local_iterator a forward iterator to const value_type * convertible to const_local_iterator const_local_iterator a forward iterator to const value_type * size_type an unsigned integral type usually the same as size_t difference_type a signed integral type usually the same as ptrdiff_t *Note: All iterators in a unordered_multiset point to const elements. Whether the const_ member type is the same type as its non-const_ counterpart depends on the particular library implementation, but programs should not rely on them being different to overload functions: const_iterator is more generic, since iterator is always convertible to it.


The same applies to local_ and non-local_ iterator types: they may either be the same type or not, but a program should not rely on them being different.

Member functions
(constructor)
Construct unordered_multiset (public member function)
(destructor)
Destroy unordered multiset (public member function)
operator=
Assign content (public member function)

Capacity
empty
Test whether container is empty (public member function)
size
Return container size (public member function)
max_size
Return maximum size (public member function)

Iterators
begin
Return iterator to beginning (public member type)
end
Return iterator to end (public member type)
cbegin
Return const_iterator to beginning (public member type)
cend
Return const_iterator to end (public member type)

Element lookup
find
Get iterator to element (public member function)
count
Count elements with a specific key (public member function)
equal_range
Get range of elements with specific key (public member function)

Modifiers
emplace
Construct and insert element (public member function)
emplace_hint
Construct and insert element with hint (public member function)
insert
Insert elements (public member function)
erase
Erase elements (public member function)
clear
Clear content (public member function)
swap
Swap content (public member function)

Buckets
bucket_count
Return number of buckets (public member function)
max_bucket_count
Return maximum number of buckets (public member function)
bucket_size
Return bucket size (public member type)
bucket
Locate element's bucket (public member function)

Hash policy
load_factor
Return load factor (public member function)
max_load_factor
Get or set maximum load factor (public member function)
rehash
Set number of buckets (public member function)
reserve
Request a capacity change (public member function)

Observers
hash_function
Get hash function (public member type)
key_eq
Get key equivalence predicate (public member type)
get_allocator
Get allocator (public member function)

Non-member function overloads
operators (unordered_multiset)
Relational operators for unordered_multiset (function template)
swap (unordered_multiset)
Exchanges contents of two unordered_multiset containers (function template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4