multiset


A container that is optimized for fast associative lookup. Items are matched using the operator== . When an item is inserted into a multiset , the item is stored in a data structure where it can be found quickly. Within the data structure, the items are ordered according to a user-defined comparator function object. A typical user-supplied function object is less, which orders the items in ascending order. Unlike a set , a multiset can contain multiple copies of the same item.

Library

Standards<ToolKit>

Declaration


#include <set>

template< class T, class Compare, class Allocator >
class multiset

Interface

Constructor
multiset()
Constructs an empty multiset that orders elements using the comparator Compare() and manages storage using Allocator() .
Constructor
explicit multiset( const Compare& compare , const Allocator& alloc )
Constructs an empty multiset that orders elements using the comparator compare and manages storage using alloc (default Allocator() ).
Constructor
multiset( const T* first , const T* last , const Compare& compare , const Allocator& alloc )
Constructs a multiset that contains copies of the elements in the range [ first , last ) , using compare (default Compare() ) to order the elements, and using alloc (default Allocator() ) to manage storage.
Constructor
multiset( const_iterator first , const_iterator last , const Compare& compare , const Allocator& alloc )
Constructs a multiset that contains copies of the elements in the range [ first , last ) , using compare (default Compare() ) to order the elements, and using alloc (default Allocator() ) to manage storage.
Constructor
multiset( const multiset< T, Compare, Allocator >& other )
Constructs a copy of other .
Destructor
~multiset()
Destroys the multiset and erases all of its items.
=
multiset< T, Compare, Allocator >& operator=( const multiset< T, Compare, Allocator >& other )
Replaces the contents of the multiset with a copy of other .
begin
iterator begin()
Returns an iterator positioned at the multiset's first item.
begin
const_iterator begin() const
Returns a constant iterator positioned at the multiset's first item.
clear
void clear()
Erases all of the multiset's elements.
count
size_type count( const T& value ) const
Returns the number of elements multiset contains that match value .
empty
bool empty() const
Returns true if the multiset contains no entries.
end
iterator end()
Returns an iterator positioned immediately after the multiset's last item.
end
const_iterator end() const
Returns a constant iterator positioned immediately after the multiset's last item.
equal_range
pair< iterator, iterator > equal_range( const T& value )
Returns a pair of iterators with a first element that is equal to lower_bound() and a second element that is equal to upper_bound() .
equal_range
pair< const_iterator, const_iterator >
equal_range( const T&
value ) const
Returns a pair of iterators with a first element that is equal to lower_bound() and a second element that is equal to upper_bound() .
erase
void erase( iterator pos )
Erases the element at pos .
erase
void erase( iterator first , iterator last )
Erases elements in the range [ first , last ) .
erase
size_type erase( const T& value )
Erases all elements that match value and returns the number of elements erased.
find
iterator find( const T& value )
If the multiset contains an element that matches value , returns an iterator positioned at the matching element. Otherwise, returns an iterator positioned at end() .
find
const_iterator find( const T& value ) const
If the multiset contains an element that matches value , returns an iterator positioned at the matching element. Otherwise, returns an iterator positioned at end() .
get_allocator
Allocator get_allocator() const
Returns a copy of the allocator used to manage storage.
insert
iterator insert( const T& value )
Inserts a copy of value and returns an iterator positioned at the new element.
insert
void insert( const T* first , const T* last )
Inserts copies of the elements in the range [ first , last ) .
insert
void insert( const_iterator first , const_iterator last )
Inserts copies of the elements in the range [ first , last ) .
insert
iterator insert( iterator pos , const T& value )
Inserts a copy of value and returns an iterator positioned at the new element. Uses pos as a hint on where to start searching for the correct place to insert.
key_comp
Compare key_comp() const
Returns the comparison object.
lower_bound
iterator lower_bound( const T& value )
Returns an iterator positioned at the first location value could be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
lower_bound
const_iterator lower_bound( const T& value ) const
Returns a constant iterator positioned at the first location value could be inserted without violating the ordering criteria. If no such location is found, returns a constant iterator positioned at end() .
max_size
size_type max_size() const
Returns the maximum number of entries the multiset can contain.
rbegin
reverse_iterator rbegin()
Returns a reverse iterator positioned at the multiset's last item.
rbegin
const_reverse_iterator rbegin() const
Returns a constant reverse iterator positioned at the multiset's last item.
rend
reverse_iterator rend()
Returns a reverse iterator positioned immediately before the multiset's first item.
rend
const_reverse_iterator rend() const
Returns a constant reverse iterator positioned immediately before the multiset's first item.
size
size_type size() const
Returns the number of entries the multiset contains.
swap
void swap( multiset< T, Compare, Allocator >& other )
Exchanges the contents of multiset and other .
upper_bound
iterator upper_bound( const T& value )
Returns an iterator positioned at the last location value can be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
upper_bound
const_iterator upper_bound( const T& value ) const
Returns a constant iterator positioned at the last location value can be inserted without violating the ordering criteria. If no such location is found, returns a constant iterator positioned at end() .
value_comp
Compare value_comp() const
Returns the comparison object.

Non-Member Functions

==
bool operator==( const multiset< T, Compare, Allocator >& x , const multiset< T, Compare, Allocator >& y )
Returns true if x contains the same items in the same order as y .
<
bool operator<( const multiset< T, Compare, Allocator >& x , const multiset< T, Compare, Allocator >& y )
Returns true if x is lexicographically less than y .
swap
void swap( const multiset< T, Compare, Allocator >& x , const multiset< T, Compare, Allocator >& y )
Exchanges the contents of x and y .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.