📄 mul_0958.htm
字号:
<HTML><TITLE>multiset</TITLE><BODY>
<A HREF="ref.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the Class Reference home page.</STRONG></P>
<P>©Copyright 1996 Rogue Wave Software</P>
<H2>multiset</H2>
<HR><PRE> Container Class</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>An associative container providing fast access to stored key values. Storage of duplicate keys is allowed. A <B><I>multiset</B></I> supports bidirectional iterators.</P>
<H3>Contents</H3>
<UL>
<A HREF="#Synopsis"><LI>Synopsis</LI></A>
<A HREF="#Description"><LI>Description</LI></A>
<A HREF="#Interface"><LI>Interface</LI></A>
<A HREF="#Constructor and Destructor"><LI>Constructor and Destructor</LI></A>
<A HREF="#Assignment Operator"><LI>Assignment Operator</LI></A>
<A HREF="#Allocator"><LI>Allocator</LI></A>
<A HREF="#Iterators"><LI>Iterators</LI></A>
<A HREF="#Member Functions"><LI>Member Functions</LI></A>
<A HREF="#Non-member Operators"><LI>Non-member Operators</LI></A>
<A HREF="#Example"><LI>Example</LI></A>
<A HREF="#Warnings"><LI>Warnings</LI></A>
<A HREF="#See Also"><LI>See Also</LI></A>
</UL>
<A NAME="Synopsis"><H3>Synopsis</H3></A>
<PRE>#include <set></PRE>
<PRE>
template <class Key, class Compare = less<Key>,
class Allocator = allocator>
class <B>multiset</B>;</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>multiset <Key, Compare, Allocator> </B></I>provides fast access to stored key values. The default operation for key comparison is the <SAMP><</SAMP> operator. Insertion of dupliate keys is allowed with a multiset. </P>
<P><B><I>multiset</B></I> provides bidirectional iterators which point to a stored key. </P>
<P>Any type used for the template parameter <SAMP>Key</SAMP> must provide the following (where<SAMP> T</SAMP> is the <SAMP>type</SAMP>,<SAMP> t</SAMP> is a value of <SAMP>T</SAMP> and<SAMP> u</SAMP> is a <SAMP>const</SAMP> <SAMP>value</SAMP> of <SAMP>T</SAMP>): </P>
<PRE> 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
(possibley const) value of T</PRE><P>The <SAMP>type</SAMP> used for the <SAMP>Compare</SAMP> template parameter must satisfy the requirements for binary functions. </P>
<A NAME="Interface"><H3>Interface</H3></A>
<PRE>template <class Key, class Compare = less<Key>,
class Allocator = allocator>
class multiset {
public:
// typedefs
typedef Key key_type;
typedef Key value_type;
typedef Compare key_compare;
typedef Compare value_compare;
typedef Allocator allocator_type;
typename reference;
typename const_reference;
typename iterator;
typename const_iterator;
typename size_type;
typename difference_type;
typename reverse_iterator;
typename const_reverse_iterator;
// Construct/Copy/Destroy
explicit multiset (const Compare& = Compare(),
const Allocator& = Allocator());
template <class InputIterator>
multiset (InputIterator, InputIterator,
const Compare& = Compare(),
const Allocator& = Allocator());
multiset (const multiset<Key, Compare, Allocator>&);
~multiset ();
multiset<Key, Compare, Allocator>& operator= (const multiset<Key,
Compare,
Allocator>&);
// Iterators
iterator begin ();
const_iterator begin () const;
iterator end ();
const_iterator end () const;
reverse_iterator rbegin ();
const_reverse_iterator rbegin () const;
reverse_iterator rend ();
const_reverse_iterator rend () const;
// Capacity
bool empty () const;
size_type size () const;
size_type max_size () const;
// Modifiers
iterator insert (const value_type&);
iterator insert (iterator, const value_type&);
template <class InputIterator>
void insert (InputIterator, InputIterator);
iterator erase (iterator);
size_type erase (const key_type&);
iterator erase (iterator, iterator);
void swap (multiset<Key, Compare, Allocator>&);
void clear ();
// Observers
key_compare key_comp () const;
value_compare value_comp () const;
// Multiset operations
iterator find (const key_type&) const;
size_type count (const key_type&) const;
iterator lower_bound (const key_type&) const;
iterator upper_bound (const key_type&) const;
pair<iterator, iterator> equal_range (const key_type&) const;
};
// Non-member Operators
template <class Key, class Compare, class Allocator>
bool operator==
(const multiset<Key, Compare, Allocator>&,
const multiset<Key, Compare, Allocator>&);
template <class Key, class Compare, class Allocator>
bool operator<
(const multiset<Key, Compare, Allocator>&,
const multiset<Key, Compare, Allocator>&);
// Specialized Algorithms
template <class Key, class Compare, class Allocator>
void swap ( multiset<Key, Compare, Allocator>&,
multiset<Key, Compare, Allocator>&);
</PRE>
<A NAME="Constructor and Destructor"><H3>Constructor and Destructor</H3></A>
<PRE>explicit <B>multiset</B> (const Compare& comp = Compare(),
const Allocator& alloc = Allocator());</PRE>
<UL><P>Default constructor. Constructs an empty multiset which will use the optional relation <SAMP>comp</SAMP> to order keys, if it is supplied, and the allocator <SAMP>alloc </SAMP>for all storage management. </P>
</UL>
<PRE>template <class InputIterator>
<B>multiset</B> (InputIterator first, InputIterator last,
const Compare& = Compare(),
const Allocator& = Allocator());</PRE>
<UL><P>Constructs a multiset containing values in the range <SAMP>[first, last).</SAMP></P>
</UL>
<PRE><B>multiset</B> (const multiset<Key, Compare, Allocator>& x);</PRE>
<UL><P>Copy constructor. Creates a new multiset by copying all key values from <SAMP>x</SAMP>. </P>
</UL>
<PRE><B>~multiset</B> ();</PRE>
<UL><P>The destructor. Releases any allocated memory for this multiset.</P>
</UL>
<A NAME="Assignment Operator"><H3>Assignment Operator</H3></A>
<PRE>multiset<Key, Compare, Allocator>&
<B>operator= </B>(const multiset<Key, Compare, Allocator>& x);</PRE>
<UL><P>Replaces the contents of <SAMP>*this</SAMP> with a copy of the contents of <SAMP>x</SAMP>. </P>
</UL>
<A NAME="Allocator"><H3>Allocator</H3></A>
<PRE>allocator_type <B>get_allocator</B> () const;</PRE>
<UL><P>Returns a copy of the allocator used by self for storage management.</P>
</UL>
<A NAME="Iterators"><H3>Iterators</H3></A>
<PRE>iterator <B>begin</B>();</PRE>
<UL><P>Returns an <SAMP>iterator</SAMP> pointing to the first element stored in the multiset. "First" is defined by the multiset's comparison operator, <SAMP>Compare</SAMP>. </P>
</UL>
<PRE>const_iterator <B>begin</B>();</PRE>
<UL><P>Returns a <SAMP>const_iterator</SAMP> pointing to the first element stored in the multiset. </P>
</UL>
<PRE>iterator <B>end</B>();</PRE>
<UL><P>Returns an <SAMP>iterator</SAMP> pointing to the last element stored in the multiset, i.e., the off-the-end value. </P>
</UL>
<PRE>const_iterator <B>end</B>();</PRE>
<UL><P>Returns a <SAMP>const_iterator</SAMP> pointing to the last element stored in the multiset, i.e., the off-the-end value. </P>
</UL>
<PRE>reverse_iterator <B>rbegin</B>();</PRE>
<UL><P>Returns a <SAMP>reverse_iterator</SAMP> pointing to the first element stored in the multiset. "First" is defined by the multiset's comparison operator, <SAMP>Compare</SAMP>. </P>
</UL>
<PRE>const_reverse_iterator <B>rbegin</B>();</PRE>
<UL><P>Returns a <SAMP>const_reverse_iterator</SAMP> pointing to the first element stored in the multiset. </P>
</UL>
<PRE>reverse_iterator <B>rend</B>();</PRE>
<UL><P>Returns a <SAMP>reverse_iterator</SAMP> pointing to the last element stored in the multiset, i.e., the off-the-end value. </P>
</UL>
<PRE>const_reverse_iterator <B>rend</B>();</PRE>
<UL><P>Returns a <SAMP>const_reverse_iterator</SAMP> pointing to the last element stored in the multiset, i.e., the off-the-end value. </P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -