⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set_1649.htm

📁 ARM编辑、编译软件
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><TITLE>set</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>&copy;Copyright 1996 Rogue Wave Software</P>
<H2>set</H2>
<HR><PRE>     Container</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>An associative container that supports unique keys.  A <B><I>set</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="#Constructors and Destructors"><LI>Constructors and Destructors</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 &#60;set></PRE>
<PRE>
template &#60;class Key, class Compare = less&#60;Key>,
  class Allocator = allocator>
class <B>set</B> ;
</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>set&#60;Key, Compare, Allocator> </B></I>is an associative container that supports unique keys and provides for fast retrieval of the keys.  A <B><I>set</B></I> contains at most one of any key value.  The keys are sorted using <SAMP>Compare</SAMP>. </P>
<P>Since a <B><I>set</B></I> maintains a total order on its elements, you cannot alter the key values directly.  Instead, you must insert new elements with an<SAMP> insert_iterator</SAMP>. </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 <SAMP>value</SAMP> 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            &#38;t and &#38;u yielding T* and
                        const T* respectively
  Assignment            t = a where a is a
                       (possibly 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 &#60;class Key, class Compare = less&#60;Key>,
          class Allocator = allocator>
 class set {
public:
 // types
   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 set (const Compare&#38; = Compare(), 
                 const Allocator&#38; = Allocator ());
   template &#60;class InputIterator>
    set (InputIterator, InputIterator, const Compare&#38; = Compare(),
         const Allocator&#38; = Allocator ());
   set (const set&#60;Key, Compare, Allocator>&#38;);
   ~set ();
   set&#60;Key, Compare, Allocator>&#38; operator= (const set &#60;Key, Compare, 
                                                       Allocator>&#38;);
   allocator_type get_allocator () const;
 // 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
   pair&#60;iterator, bool> insert (const value_type&#38;);
   iterator insert (iterator, const value_type&#38;);
   template &#60;class InputIterator>
    void insert (InputIterator, InputIterator);
   iterator erase (iterator);
   size_type erase (const key_type&#38;);
   iterator erase (iterator, iterator);
   void swap (set&#60;Key, Compare, Allocator>&#38;);
   void clear ();
 // Observers
   key_compare key_comp () const;
   value_compare value_comp () const;
 // Set operations
   size_type count (const key_type&#38;) const;
   pair&#60;iterator, iterator> equal_range (const  key_type&#38;) const;
   iterator find (const key_type&#38;) const;
   iterator lower_bound (const key_type&#38;) const;
   iterator upper_bound (const key_type&#38;) const
};
 // Non-member Operators
template &#60;class Key, class Compare, class Allocator>
 bool operator== (const set&#60;Key, Compare, Allocator>&#38;,
                  const set&#60;Key, Compare, Allocator>&#38;);
template &#60;class Key, class Compare, class Allocator>
 bool operator&#60; (const set&#60;Key, Compare, Allocator>&#38;,
                 const set&#60;Key, Compare, Allocator>&#38;);
// Specialized Algorithms
template &#60;class Key, class Compare, class Allocator>
void swap (set &#60;Key, Compare, Allocator>&#38;,
           set &#60;Key, Compare, Allocator>&#38;);
</PRE>
<A NAME="Constructors and Destructors"><H3>Constructors and Destructors</H3></A>
<PRE>explicit 
<B>set</B> (const Compare&#38; comp = Compare(),
     const Allocator&#38; alloc = Allocator ());</PRE>
<UL><P>The default constructor.  Creates a set of zero elements.  If the function object <SAMP>comp</SAMP> is supplied, it is used to compare elements of the set.   Otherwise, the default function object in the template argument is used.  The template argument defaults to <SAMP>less (&#60;)</SAMP>. The allocator <SAMP>alloc</SAMP> is used for all storage management.</P>
</UL>
<PRE>template &#60;class InputIterator>
<B>set</B> (InputIterator first, InputIterator last, 
     const Compare&#38; comp = Compare ()
     const Allocator&#38; alloc = Allocator());</PRE>
<UL><P>Creates a set of length <SAMP>last - first</SAMP>, filled with all values obtained by dereferencing the <SAMP>InputIterators</SAMP> on the range <SAMP>[first, last)</SAMP>.  If the function object <SAMP>comp</SAMP> is supplied, it is used to compare elements of the set.  Otherwise, the default function object in the template argument is used.  The template argument defaults to <SAMP>less (&#60;)</SAMP>. Uses the allocator <SAMP>alloc</SAMP> for all storage management. </P>
</UL>
<PRE><B>set</B> (const set&#60;Key, Compare, Allocator>&#38; x);</PRE>
<UL><P>Copy constructor. Creates a copy of <SAMP>x</SAMP>.</P>
</UL>
<PRE><B>~set</B> ();</PRE>
<UL><P>The destructor.  Releases any allocated memory for self.</P>
</UL>
<A NAME="Assignment Operator"><H3>Assignment Operator</H3></A>
<PRE>set&#60;Key, Compare, Allocator>&#38; 
<B>operator=</B> (const set&#60;Key, Compare, Allocator>&#38; x);</PRE>
<UL><P>Assignment operator.  Self will share an implementation with <SAMP>x</SAMP>.  Returns a reference to self.</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> that points to the first element in self.</P>
</UL>
<PRE>const_iterator <B>begin</B> () const;</PRE>
<UL><P>Returns a <SAMP>const_iterator</SAMP> that points to the first element in self.</P>
</UL>
<PRE>iterator <B>end</B> ();</PRE>
<UL><P>Returns an <SAMP>iterator</SAMP> that points to the past-the-end value.</P>
</UL>
<PRE>const_iterator <B>end</B> () const;</PRE>
<UL><P>Returns a <SAMP>const_iterator</SAMP> that points to the past-the-end value.</P>
</UL>
<PRE>reverse_iterator <B>rbegin</B> ();</PRE>
<UL><P>Returns a <SAMP>reverse_iterator</SAMP> that points to the past-the-end value.</P>
</UL>
<PRE>const_reverse_iterator <B>rbegin</B> () const;</PRE>
<UL><P>Returns a <SAMP>const_reverse_iterator</SAMP> that points to the past-the-end value.</P>
</UL>
<PRE>reverse_iterator <B>rend</B> ();</PRE>
<UL><P>Returns a <SAMP>reverse_iterator</SAMP> that points to the first element.</P>
</UL>
<PRE>const_reverse_iterator <B>rend</B> () const;</PRE>
<UL><P>Returns a <SAMP>const_reverse_iterator</SAMP> that points to the first element.</P>
</UL>
<A NAME="Member Functions"><H3>Member Functions</H3></A>
<PRE>void

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -