Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

multiset

Library:  Containers


Does not inherit

Local Index

Members

Non-Members

Summary

An associative container that allows fast access to stored key values. Storage of duplicate keys is allowed. A multiset supports bidirectional iterators.

Synopsis

#include <set>

namespace std {
  template <class Key, class Compare = less<Key>,
            class Allocator = allocator<Key> > 
  class multiset;
}

Description

multiset allows fast access to stored key values. The default operation for key comparison is the < operator. Insertion of duplicate keys is allowed with a multiset.

multiset uses bidirectional iterators that point to a stored key.

Any type used for the template parameter Key must include the following (where T is the type, t is a value of T and u is a const value of T):

Copy constructors

T(t) and T(u)

Destructor

t.~T()

Address of

&t and &u yielding T* and const T* respectively

Assignment

t = a where a is a (possibly const) value of T

The type used for the Compare template parameter must satisfy the requirements for binary functions.

Interface

Constructors

explicit multiset(const Compare& comp = Compare(),
                   const Allocator& alloc = Allocator());
template <class InputIterator>
multiset(InputIterator start, InputIterator finish,
          const Compare& = Compare(),
          const Allocator& = Allocator());
multiset(const multiset<Key, Compare, Allocator>& x);

Destructors

~multiset();

Assignment Operators

multiset<Key, Compare, Allocator>& 
operator=(const multiset<Key, Compare, Allocator>& x);

Allocators

allocator_type 
get_allocator() const;

Iterators

iterator 
begin();
const_iterator 
begin();
iterator 
end();
const_iterator 
end();
reverse_iterator 
rbegin();
const_reverse_iterator 
rbegin();
reverse_iterator 
rend();
const_reverse_iterator 
rend();

Member Functions

void
clear();
size_type 
count(const key_type& x) const;
bool 
empty() const;
pair<iterator,iterator> 
equal_range(const key_type& x)const;
size_type 
erase(const key_type& x);
void
erase(iterator position);
void
erase(iterator start, iterator finish);
iterator 
find(const key_type& x) const;
iterator 
insert(const value_type& x);
iterator 
insert(iterator position, const value_type& x);
template <class InputIterator>
void 
insert(InputIterator start, InputIterator finish);
key_compare 
key_comp() const;
iterator 
lower_bound(const key_type& x) const;
size_type 
max_size() const;
size_type
size() const;
void 
swap(multiset<Key, Compare, Allocator>& x);
iterator 
upper_bound(const key_type& x) const;
value_compare 
value_comp() const;

Nonmember Operators

template <class Key, class Compare, class Allocator>
operator==(const multiset<Key, Compare, Allocator>& x,
            const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
operator!=(const multiset<Key, Compare, Allocator>& x,
            const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
operator<(const multiset<Key, Compare, Allocator>& x,
           const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
operator>(const multiset<Key, Compare, Allocator>& x,
           const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
operator<=(const multiset<Key, Compare, Allocator>& x,
           const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
operator>=(const multiset<Key, Compare, Allocator>& x,
           const multiset<Key, Compare, Allocator>& y);

Specialized Algorithms

template <class Key, class Compare, class Allocator>
void swap(multiset<Key,Compare,Allocator>& a,
          multiset<Key,Compare,Allocator>&b);

Example

Warnings

Member function templates are used in all containers included in the Standard Template Library. For example, the constructor for multiset takes two templatized iterators:

multiset also has an insert function of this type. These functions, when not restricted by compiler limitations, allow you to use any type of input iterator as arguments. For compilers that do not support this feature, substitute functions allow you to use an iterator obtained from the same type of container as the one you are constructing (or calling a member function on). You can also use a pointer to the type of element you have in the container.

For example, if your compiler does not support member function templates, you can construct a multiset in the following two ways:

You cannot construct a multiset this way:

since the long_multiset and first_multiset are not the same type.

If your compiler is does not support default template parameters, you must always supply the Compare template argument and the Allocator template argument. For instance, you must write:

multiset<int, less<int>, allocator<int> >

instead of:

multiset<int>

See Also

allocator, Containers, Iterators, set

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 23.3.4



Previous fileTop of DocumentContentsIndex pageNext file