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

📄 set_4687.htm

📁 C++标准库 C++标准库 C++标准库 C++标准库
💻 HTM
字号:
<HTML><HEAD><TITLE>8.1 The set Data Abstraction</TITLE></HEAD><BODY><A HREF="ug1.htm"><IMG SRC="images/banner.gif"></A><BR><A HREF="set_3455.htm"><IMG SRC="images/prev.gif"></A><A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="set_1754.htm"><IMG SRC="images/next.gif"></A><BR><STRONG>Click on the banner to return to the user guide home page.</STRONG><H2>8.1 The set Data Abstraction</H2><A HREF="sidebar1.htm#sidebar23"><IMG SRC="images/note.gif" BORDER=0> <STRONG>Sets, Ordered and Not</STRONG></A><A NAME="idx82"><!></A><P>A <I>set</I> is a collection of values.  Because the container used to implement the <A HREF="../stdlibcr/set_1649.htm"><B><I>set</I></B></A> data structure maintains values in an ordered representation, sets are optimized for insertion and removal of elements, and for testing to see whether a particular value is contained in the collection.  Each of these operations can be performed in a logarithmic number of steps, whereas for a <A HREF="../stdlibcr/lis_3222.htm"><B><I>list</I></B></A>, <A HREF="../stdlibcr/vec_0251.htm"><B><I>vector</I></B></A>, or <A HREF="../stdlibcr/deq_4164.htm"><B><I>deque</I></B></A>, each operation requires in the worst case an examination of every element held by the container.  For this reason, sets should be the data structure of choice in any problem that emphasizes insertion, removal, and test for inclusion of values.  Like a <B><I>list</I></B>, a <B><I>set</I></B> is not limited in size, but rather expands and contracts as elements are added to or removed from the collection.</P><P>There are two varieties of sets provided by the standard library.  In the <A HREF="../stdlibcr/set_1649.htm"><B><I>set</I></B></A> container, every element is unique.  Insertions of values that are already contained in the set are ignored.  In the <A HREF="../stdlibcr/mul_0958.htm"><B><I>multiset</I></B></A> container, on the other hand, multiple occurrences of the same value are permitted.</P><A NAME="8.1.1"><H3>8.1.1 Include Files</H3></A><P>Whenever you use a <A HREF="../stdlibcr/set_1649.htm"><B><I>set</I></B></A> or a <A HREF="../stdlibcr/mul_0958.htm"><B><I>multiset</I></B></A>, you must include the set header file.</P><PRE>   # include &#60;set></PRE><HR><A HREF="set_3455.htm"><IMG SRC="images/prev.gif"></A> <A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="set_1754.htm"><IMG SRC="images/next.gif"></A><P>&copy;Copyright 1996, Rogue Wave Software, Inc.</P></BODY></HTML>

⌨️ 快捷键说明

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