You were redirected to cplusplus.com/multiset || See search results for: "multiset"
class template
<set>

std::multiset

template < class T,                        // multiset::key_type/value_type
           class Compare = less<T>,        // multiset::key_compare/value_compare
           class Alloc = allocator<T> >    // multiset::allocator_type
           > class multiset;
Multiple-key set
Multisets are containers that store elements following a specific order, and where multiple elements can have equivalent values.

In a multiset, the value of an element also identifies it (the value is itself the key, of type T). The value of the elements in a multiset cannot be modified once in the container (the elements are always const), but they can be inserted or removed from the container.

Internally, the elements in a multiset are always sorted following a specific strict weak ordering criterion indicated by its internal comparison object (of type Compare).

multiset containers are generally slower than unordered_multiset containers to access individual elements by their key, but they allow the direct iteration on subsets based on their order.

Multisets are typically implemented as binary search trees.

Container properties

Associative
Elements in associative containers are referenced by their key and not by their absolute position in the container.
Ordered
The elements in the container follow a strict order at all times. All inserted elements are given a position in this order.
Set
The value of an element is also the key used to identify it.
Multiple equivalent keys
Multiple elements in the container can have equivalent keys.
Allocator-aware
The container uses an allocator object to dynamically handle its storage needs.

Template parameters

T
Type of the elements. Each element in a multiset container is also identified by this value (each value is itself also the element's key).
Aliased as member types multiset::key_type and multiset::value_type.
Compare
A binary predicate that takes two arguments of the same type as the elements and returns a bool. The expression comp(a,b), where comp is an object of this type and a and b are key values, shall return true if a is considered to go before b in the strict weak ordering the function defines.
The multiset object uses this expression to determine both the order the elements follow in the container and whether two element keys are equivalent (by comparing them reflexively: they are equivalent if !comp(a,b) && !comp(b,a)).
This can be a function pointer or a function object (see constructor for an example). This defaults to less<T>, which returns the same as applying the less-than operator (a<b).
Aliased as member types multiset::key_compare and multiset::value_compare.
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 multiset::allocator_type.

Member types

member typedefinitionnotes
key_typeThe first template parameter (T)
value_typeThe first template parameter (T)
key_compareThe second template parameter (Compare)defaults to: less<key_type>
value_compareThe second template parameter (Compare)defaults to: less<value_type>
allocator_typeThe third template parameter (Alloc)defaults to: allocator<value_type>
referenceallocator_type::referencefor the default allocator: value_type&
const_referenceallocator_type::const_referencefor the default allocator: const value_type&
pointerallocator_type::pointerfor the default allocator: value_type*
const_pointerallocator_type::const_pointerfor the default allocator: const value_type*
iteratora bidirectional iterator to value_typeconvertible to const_iterator
const_iteratora bidirectional iterator to const value_type
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator>
difference_typea signed integral type, identical to: iterator_traits<iterator>::difference_typeusually the same as ptrdiff_t
size_typean unsigned integral type that can represent any non-negative value of difference_typeusually the same as size_t
member typedefinitionnotes
key_typeThe first template parameter (T)
value_typeThe first template parameter (T)
key_compareThe second template parameter (Compare)defaults to: less<key_type>
value_compareThe second template parameter (Compare)defaults to: less<value_type>
allocator_typeThe third template parameter (Alloc)defaults to: allocator<value_type>
referencevalue_type&
const_referenceconst value_type&
pointerallocator_traits<allocator_type>::pointerfor the default allocator: value_type*
const_pointerallocator_traits<allocator_type>::const_pointerfor the default allocator: const value_type*
iteratora bidirectional iterator to const value_type* convertible to const_iterator
const_iteratora bidirectional iterator to const value_type*
reverse_iteratorreverse_iterator<iterator>*
const_reverse_iteratorreverse_iterator<const_iterator>*
difference_typea signed integral type, identical to:
iterator_traits<iterator>::difference_type
usually the same as ptrdiff_t
size_typean unsigned integral type that can represent any non-negative value of difference_typeusually the same as size_t
*Note: All iterators in a 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.

Member functions


Iterators:

Capacity:

Modifiers:

Observers:

Operations:

Allocator: