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

📄 set.htm

📁 这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明
💻 HTM
字号:
<html>
<head>
<title> The set Class</title>
</head>

<body bgcolor="#FFFFFF">

<img src="setban.gif">

<pre>
<font size=5>Class Name</font>            set

<font size=5>Header File</font>           &lt;set&gt;

<font size=5>Classification</font>      Container
</pre>

<a href="set.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>


<i>None</i>


<h1>Methods</h1>
<pre>

<a href="common.htm#begin">iterator begin()</a><br>
<a href="common.htm#begin">const_iterator begin() const</a><br>
<a href="list.htm#clear">void clear()</a><br>
<a href="assoc.htm#count">size_type count(const key_type& x) const</a><br>
<a href="common.htm#empty">bool empty() const</a><br>
<a href="common.htm#end">iterator end()</a><br>
<a href="common.htm#end">const_iterator end() const</a><br>
<a href="assoc.htm#erase1">void erase(iterator position)</a><br>
<a href="assoc.htm#erase2">size_type erase(const key_type& x)</a><br>
<a href="assoc.htm#erase3">void erase(iterator first, iterator last)</a><br>
<a href="assoc.htm#equal">pair&lt;iterator,iterator&gt; equal_range(const key_type& x) const</a><br>
<a href="assoc.htm#find1">iterator find(const key_type& x) const</a><br>
<a href="list.htm#getallocator">allocator_type get_allocator() const</a><br>
<a href="assoc.htm#insert1">pair&lt;iterator,bool&gt; insert(const value_type& x)</a><br>
<a href="assoc.htm#insert2">iterator insert(iterator position, const value_type& x)</a><br>
<a href="assoc.htm#insert3">template &lt;class InputIterator&gt;void insert(InputIterator first, InputIterator last)</a><br>
<a href="assoc.htm#lower">iterator lower_bound(const key_type& x) const</a><br>
<a href="common.htm#maxsize">size_type max_size() const</a><br>
<a href="common.htm#rbegin">reverse_iterator rbegin()</a><br>
<a href="common.htm#rbegin">const_reverse_iterator rbegin() const</a><br>
<a href="common.htm#rend">reverse_iterator rend()</a><br>
<a href="list.htm#resize">void resize(size_type Sz, T C = T())</a><br>
<a href="common.htm#rend">const_reverse_iterator rend() const</a><br>
<a href="set.htm#set1">explicit set(const Compare& comp = Compare(), const Allocator& = Allocator())</a><br>
<a href="set.htm#set2">template &lt;class InputIterator&gt; set(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())</a><br>
<a href="set.htm#set3">set(const set&lt;Key,Compare,Allocator&gt;& X)</a><br>
<a href="set.htm#set4">~set()</a><br>
<a href="common.htm#size">size_type size() const</a><br>
<a href="set.htm#swap">void swap(set<Key,Compare,Allocator>& X)</a><br>
<a href="assoc.htm#upper">iterator upper_bound(const key_type& x) const</a><br>
</pre>


<h2>Operators</h2>

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



<a href="set.htm#example"><h2>Example</h2></a><br>
<hr>
<a name="desc"><h3>Class Description</h3></a>
<p>
A set container can be used to represent a collection of  people, places, things, or ideas.  
An important characteristic of sets is that they only allow an object to be included once in the set.
That is each element must have a unique key.

</p>
<hr>

<pre>
<a name="swap">Method            swap()</a>

Access            Public

Classification    Modifier

Syntax            void swap(set&lt;Key,Compare,Allocator&gt;& X)

Parameters        X is the set to be swapped with the contents of the current set.

Return            X is the set to be swapped.

</pre>

<h3>Description</h3>
<p>

The swap() method swaps the contents of the current set with set X.

</p>
<hr>

<pre>
<a name="set1">Method            set()</a>

Access            Public

Classification    Constructor

Syntax            explicit set(const Compare& Comp = Compare(), const Allocator &X = Allocator())

Parameters        Comp is the function object that will be used to order the set.
                   X is a allocator object.

Return            None.

</pre>

<h3>Description</h3>
<p>

The set() method constructs an empty set container.

</p>
<hr>

<pre>
<a name="set2">Method            set()</a>

Access            Public

Classification    Constructor

Syntax            template &lt;class InputIterator&gt; set(InputIterator first, InputIterator last,const Compare& Comp = Compare(), const Allocator&X = Allocator())

Parameters        elements from the range [first,last) will be used to construct the set. X is a allocator object.
                  Comp is the function object that will be used to order the set.

Return            None.

</pre>

<h3>Description</h3>
<p>

The set() method constructs a set that contains copies of the objects that are pointed to by the
iterators in the range [first,last].
</p>
<hr>

<pre>
<a name="set3">Method            set()</a>

Access            Public

Classification    Constructor

Syntax            set(const set&lt;Key,Compare,Allocator&gt;& X)

Parameters        X is the set that will be used to construct the new set.
                
Return            None.

</pre>

<h3>Description</h3>
<p>

The set() method constructs a  new set from set X.
</p>
<hr>

<pre>
<a name="set4">Method            set()</a>

Access            Public

Classification    Destructor

Syntax            ~set()

Parameters        None.
                
Return            None.

</pre>

<h3>Description</h3>
<p>

The ~set() method destructs a set object.
</p>
<hr>

<a name="example"></a>
<img src="lego.gif">
<pre>

#include &lt;set&gt;
#include &lt;iostream&gt;
using namespace std;

void main(void)
{
   set&lt;int, less&lt;int&gt; &gt; M;
   M.insert(1960);
   M.insert(1952);
   M.insert(1771);
   M.insert(1812);
   M.insert(1960);
   M.insert(2000);
   set&lt;int, less&lt;int&gt; &gt;::iterator N= M.begin();
   cout &lt;&lt; "Number Of Elements " &lt;&lt; M.size() &lt;&lt; endl;
   while(N != M.end())
   {
             cout &lt;&lt; *N &lt;&lt; endl;
             N++;
   }
}

</pre>
<hr>
</body>
</html>





⌨️ 快捷键说明

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