cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : STL Containers : multiset
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
multiset
comparison operators
multiset::multiset
multiset::~multiset
member functions:
· multiset::begin
· multiset::clear
· multiset::count
· multiset::empty
· multiset::end
· multiset::equal_range
· multiset::erase
· multiset::find
· multiset::get_allocator
· multiset::insert
· multiset::key_comp
· multiset::lower_bound
· multiset::max_size
· multiset::operator=
· multiset::rbegin
· multiset::rend
· multiset::size
· multiset::swap
· multiset::upper_bound
· multiset::value_comp

-

multiset class template
<set>

Multiple-key set

Multisets are associative containers with the same properties as set containers, but allowing for multiple keys with equal values.

In their implementation in the C++ Standard Template Library, multiset containers take the same three template parameters as set containers:

template < class Key, class Compare = less<Key>,
           class Allocator = allocator<Key> > class set;
Where the template parameters have the following meanings:
  • Key: Key type: type of the elements contained in the container. Each elements in a multiset is also its key.
  • Compare: Comparison class: A class that takes two arguments of the same type as the container elements and returns a bool. The expression comp(a,b), where comp is an object of this class and a and b are elements of the container, shall return true if a is to be placed at an earlier position than b in a strict weak ordering operation. 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 less<Key>, which returns the same as applying the less-than operator (a<b).
    The multiset object uses this expression to determine the position of the elements in the container. All elements in a multiset container are ordered following this rule at all times.
  • Allocator: Type of the allocator object used to define the storage allocation model. By default, the allocator class template for type Key is used, which defines the simplest memory allocation model and is value-independent.
In the reference for the multiset member functions, these same names (Key, Compare and Allocator) are assumed for the template parameters.

The multiset class template is defined in header <set>.

Member functions

(constructor) Construct multiset (public member function)
(destructor) Multiset destructor (public member function)
operator= Copy container content (public member function)

Iterators:

begin Return iterator to beginning (public member function)
end Return iterator to end (public member function)
rbegin Return reverse iterator to reverse beginning (public member function)
rend Return reverse iterator to reverse end (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)

Modifiers:

insert Insert element (public member function)
erase Erase elements (public member function)
swap Swap content (public member function)
clear Clear content (public member function)

Observers:

key_comp Return comparison object (public member function)
value_comp Return comparison object (public member function)

Operations:

find Get iterator to element (public member function)
count Count elements with a specific key (public member function)
lower_bound Return iterator to lower bound (public member function)
upper_bound Return iterator to upper bound (public member function)
equal_range Get range of equal elements (public member function)

Allocator:

get_allocator Get allocator (public member function)

Member types

of template <class Key, class Compare=less<Key>, class Allocator=allocator<Key> > class multiset;

member typedefinition
key_typeKey
value_typeKey
key_compareCompare
value_compareCompare
allocator_typeAllocator
referenceAllocator::reference
const_referenceAllocator::const_reference
iteratorBidirectional iterator
const_iteratorConstant bidirectional iterator
size_typeUnsigned integral type (usually same as size_t)
difference_typeSigned integral type (usually same as ptrdiff_t)
pointerAllocator::pointer
const_pointerAllocator::const_pointer
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator>

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us