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

📄 lib_cont.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>Container</TITLE></HEAD><BODY><H1><A NAME="Containers">Containers</A></H1><HR><P>A <B><A HREF="#Containers">container</A></B> is an<A HREF="index.html#STL">STL</A> template classthat manages a sequence of elements.Such elements can be of any object type that suppliesa copy constructor, a destructor, and an assignment operator(all with sensible behavior, of course).The destructor may not throw an exception.This document describes the properties required of all suchcontainers, in terms of a generic template class <CODE>Container</CODE>.An actual container template class may have additional template parameters.It will certainly have additional member functions.</P><P>The STL template container classes are:</P><PRE>    <A HREF="deque.html#deque">deque</A>    <A HREF="hash_map.html#hash_map">hash_map</A>    <A HREF="hash_map.html#hash_multimap">hash_multimap</A>    <A HREF="hash_set.html#hash_multiset">hash_multiset</A>    <A HREF="hash_set.html#hash_set">hash_set</A>    <A HREF="list.html#list">list</A>    <A HREF="map.html#map">map</A>    <A HREF="map.html#multimap">multimap</A>    <A HREF="set.html#multiset">multiset</A>    <A HREF="set.html#set">set</A>    <A HREF="slist.html#slist">slist</A>    <A HREF="vector.html#vector">vector</A></PRE><P>The four hash containers and <CODE>slist</CODE>are not required by the C++ Standard.The Standard C++ library template class <CODE>basic_string</CODE> alsomeets the requirements for a template container class.</P><PRE>namespace std {template&lt;class Ty&gt;    class <B><A HREF="#Container">Container</A></B>;        // TEMPLATE FUNCTIONStemplate&lt;class Ty&gt;    bool <B><A HREF="#operator==">operator==</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    bool <B><A HREF="#operator!=">operator!=</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    bool <B><A HREF="#operator&lt;">operator&lt;</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    bool <B><A HREF="#operator&gt;">operator&gt;</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    bool <B><A HREF="#operator&lt;=">operator&lt;=</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    bool <B><A HREF="#operator&gt;=">operator&gt;=</A></B>(        const Container&lt;Ty&gt;&amp; left,        const Container&lt;Ty&gt;&amp; right);template&lt;class Ty&gt;    void <B><A HREF="#swap">swap</A></B>(        Container&lt;Ty&gt;&amp; left,        Container&lt;Ty&gt;&amp; right);    };</PRE><H2><A NAME="Container"><CODE>Container</CODE></A></H2><HR><P><B><CODE><A HREF="#Container::begin">begin</A>&#183; <A HREF="#Container::clear">clear</A>&#183; <A HREF="#Container::const_iterator">const_iterator</A>&#183; <A HREF="#Container::const_reference">const_reference</A>&#183; <A HREF="#Container::const_reverse_iterator">const_reverse_iterator</A>&#183; <A HREF="#Container::difference_type">difference_type</A>&#183; <A HREF="#Container::empty">empty</A>&#183; <A HREF="#Container::end">end</A>&#183; <A HREF="#Container::erase">erase</A>&#183; <A HREF="#Container::iterator">iterator</A>&#183; <A HREF="#Container::max_size">max_size</A>&#183; <A HREF="#Container::rbegin">rbegin</A>&#183; <A HREF="#Container::reference">reference</A>&#183; <A HREF="#Container::rend">rend</A>&#183; <A HREF="#Container::reverse_iterator">reverse_iterator</A>&#183; <A HREF="#Container::size">size</A>&#183; <A HREF="#Container::size_type">size_type</A>&#183; <A HREF="#Container::swap">swap</A>&#183; <A HREF="#Container::value_type">value_type</A></CODE></B></P><HR><PRE>template&lt;class Ty&gt;    class <B>Container</B> {public:    typedef T0 <B><A HREF="#Container::size_type">size_type</A></B>;    typedef T1 <B><A HREF="#Container::difference_type">difference_type</A></B>;    typedef T2 <B><A HREF="#Container::reference">reference</A></B>;    typedef T3 <B><A HREF="#Container::const_reference">const_reference</A></B>;    typedef T4 <B><A HREF="#Container::value_type">value_type</A></B>;    typedef T5 <B><A HREF="#Container::iterator">iterator</A></B>;    typedef T6 <B><A HREF="#Container::const_iterator">const_iterator</A></B>;    typedef T7 <B><A HREF="#Container::reverse_iterator">reverse_iterator</A></B>;    typedef T8 <B><A HREF="#Container::const_reverse_iterator">const_reverse_iterator</A></B>;    iterator <B><A HREF="#Container::begin">begin</A></B>();    const_iterator <B><A HREF="#Container::begin">begin</A></B>() const;    iterator <B><A HREF="#Container::end">end</A></B>();    const_iterator <B><A HREF="#Container::end">end</A></B>() const;    reverse_iterator <B><A HREF="#Container::rbegin">rbegin</A></B>();    const_reverse_iterator <B><A HREF="#Container::rbegin">rbegin</A></B>() const;    reverse_iterator <B><A HREF="#Container::rend">rend</A></B>();    const_reverse_iterator <B><A HREF="#Container::rend">rend</A></B>() const;    size_type <B><A HREF="#Container::size">size</A></B>() const;    size_type <B><A HREF="#Container::max_size">max_size</A></B>() const;    bool <B><A HREF="#Container::empty">empty</A></B>() const;    iterator <B><A HREF="#Container::erase">erase</A></B>(iterator where);    iterator <B><A HREF="#Container::erase">erase</A></B>(iterator first, iterator last);    void <B><A HREF="#Container::clear">clear</A></B>();    void <B><A HREF="#Container::swap">swap</A></B>(Container&amp; right);    };</PRE><P>The template class describes an object that controls avarying-length sequence of elements,typically of type <CODE>Ty</CODE>.The sequence is stored in different ways, depending on theactual container.</P><P>A container constructor or member function may find occasionto call the constructor <CODE>Ty(const Ty&amp;)</CODE> or the function<CODE>Ty::operator=(const Ty&amp;)</CODE>. If such a call throwsan exception, the container object is obliged to maintain its integrity,and to rethrow any exception it catches. You can safely swap, assign to,erase, or destroy a container objectafter it throws one of these exceptions.In general, however, you cannot otherwise predict the state of thesequence controlled by the container object.</P><P>A few additional caveats:</P><UL><LI>If the expression <CODE>~Ty()</CODE> throws an exception, theresulting state of the container object is undefined.</LI><LI>If the container stores an allocator object <CODE>al</CODE>,and <CODE>al</CODE> throws an exceptionother than as a result of a call to <CODE>al.allocate</CODE>,the resulting state of the container object is undefined.</LI><LI>If the container stores a function object <CODE>comp</CODE>,to determine how to order the controlled sequence, and <CODE>comp</CODE>throws an exception of any kind, the resulting state of the containerobject is undefined.</LI></UL><P>The container classes defined by STL satisfy several additionalrequirements, as described in the following paragraphs.</P><P>Container template class<CODE><A HREF="list.html">list</A></CODE> provides deterministic,and useful, behavior even in the presence of the exceptionsdescribed above. For example, if an exception is thrown during theinsertion of one or more elements, the container is left unalteredand the exception is rethrown.</P><P>For <I>all</I> the container classes defined by STL,if an exception is thrown during calls to the following memberfunctions:</P><PRE><B><A NAME="Container::insert">insert</A></B> // single element inserted at end<B><A NAME="Container::push_back">push_back</A></B><B><A NAME="Container::push_front">push_front</A></B></PRE><P>the container is left unaltered and the exception is rethrown.</P><P>For <I>all</I> the container classes defined by STL,no exception is thrown during calls to the following memberfunctions:</P><PRE><B><A NAME="Container::pop_back">pop_back</A></B><B><A NAME="Container::pop_front">pop_front</A></B></PRE><P>The member function <CODE><A HREF="#Container::erase">erase</A></CODE>throws an exception only if a<B><A NAME="copy operation">copy operation</A></B>(assignment or copy construction) throws an exception.</P><P>Moreover, no exception is thrown while copying an iterator returned by amember function.</P><P>The member function <CODE><A HREF="#Container::swap">swap</A></CODE>makes additional promises for <I>all</I> container classes defined by STL:</P><UL><LI>The member function throws an exception only if the container storesan allocator object <CODE>al</CODE>,and <CODE>al</CODE> throws an exception when copied,or if the container stores a function object <CODE>comp</CODE>,to determine how to order the controlled sequence, and <CODE>comp</CODE>throws an exception when copied.</LI><LI>References, pointers, and iterators that designate elements ofthe controlled sequences being swapped remain valid.</LI></UL><P>An object of a container class defined by STLallocates and frees storage for the sequence it controlsthrough a stored object of type <CODE>Alloc</CODE>,which is typically a template parameter. Such an<A HREF="memory.html#allocator object">allocator object</A> must havethe same external interface as an object of class<A HREF="memory.html#allocator"><CODE>allocator</CODE>&lt;Ty&gt;</A>.In particular, <CODE>Alloc</CODE> must be the same type as<CODE>Alloc::rebind&lt;value_type&gt;::other</CODE></P><P>For <I>all</I> container classes defined by STL, the member function:</P><PRE>Alloc <B><A NAME="Container::get_allocator">get_allocator</A></B>() const;</PRE><P>returns a copy of the stored allocator object.Note that the stored allocator object is <I>not</I> copied when the containerobject is assigned. All constructors initialize the value storedin <CODE>allocator</CODE>, to <CODE>Alloc()</CODE> if the constructor containsno allocator parameter.</P><P>According to the<A HREF="crit_pjp.html#C++ Standard">C++ Standard</A>a container class defined by STL can assume that:</P><UL><LI>All objects of class <CODE>Alloc</CODE> compare equal.</LI><LI>Type <CODE>Alloc::const_pointer</CODE> is the same as<CODE>const Ty *</CODE>.</LI><LI>Type <CODE>Alloc::const_reference</CODE> is the same as<CODE>const Ty&amp;</CODE>.</LI><LI>Type <CODE>Alloc::pointer</CODE> is the same as<CODE>Ty *</CODE>.</LI><LI>Type <CODE>Alloc::reference</CODE> is the same as<CODE>Ty&amp;</CODE>.</LI></UL><P>In this<A HREF="index.html#implementation">implementation</A>, however,containers do <I>not</I> make such simplifying assumptions.Thus, they work properly with allocator objects that aremore ambitious:</P><UL><LI>All objects of class <CODE>Alloc</CODE> need not compare equal.(You can maintain multiple pools of storage.)</LI><LI>Type <CODE>Alloc::const_pointer</CODE> need not be the same as<CODE>const Ty *</CODE>.(A const pointer can be a class.)</LI><LI>Type <CODE>Alloc::pointer</CODE> need not be the same as<CODE>Ty *</CODE>.(A pointer can be a class.)</LI></UL><H3><CODE><A NAME="Container::begin">Container::begin</A></CODE></H3>

⌨️ 快捷键说明

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