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

📄 iterator.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<HTML><HEAD><TITLE>&lt;iterator&gt;</TITLE></HEAD><BODY><H1><A NAME="&lt;iterator&gt;"><CODE>&lt;iterator&gt;</CODE></A></H1><HR><P><B><CODE><A HREF="#advance">advance</A>&#183; <A HREF="#back_insert_iterator">back_insert_iterator</A>&#183; <A HREF="#back_inserter">back_inserter</A>&#183; <A HREF="#bidirectional_iterator_tag">bidirectional_iterator_tag</A>&#183; <A HREF="#distance">distance</A>&#183; <A HREF="#forward_iterator_tag">forward_iterator_tag</A>&#183; <A HREF="#front_insert_iterator">front_insert_iterator</A>&#183; <A HREF="#front_inserter">front_inserter</A>&#183; <A HREF="#input_iterator_tag">input_iterator_tag</A>&#183; <A HREF="#insert_iterator">insert_iterator</A>&#183; <A HREF="#inserter">inserter</A>&#183; <A HREF="#istream_iterator">istream_iterator</A>&#183; <A HREF="#istreambuf_iterator">istreambuf_iterator</A>&#183; <A HREF="#iterator">iterator</A>&#183; <A HREF="#iterator_traits">iterator_traits</A>&#183; <A HREF="#operator!=">operator!=</A>&#183; <A HREF="#operator==">operator==</A>&#183; <A HREF="#operator&lt;">operator&lt;</A>&#183; <A HREF="#operator&lt;=">operator&lt;=</A>&#183; <A HREF="#operator&gt;">operator&gt;</A>&#183; <A HREF="#operator&gt;=">operator&gt;=</A>&#183; <A HREF="#operator+">operator+</A>&#183; <A HREF="#operator-">operator-</A>&#183; <A HREF="#ostream_iterator">ostream_iterator</A>&#183; <A HREF="#ostreambuf_iterator">ostreambuf_iterator</A>&#183; <A HREF="#output_iterator_tag">output_iterator_tag</A>&#183; <A HREF="#random_access_iterator_tag">random_access_iterator_tag</A>&#183; <A HREF="#reverse_iterator">reverse_iterator</A></CODE></B></P><HR><P>Include the <A HREF="index.html#STL">STL</A>standard header <B><CODE>&lt;iterator&gt;</CODE></B>to define a number of classes, template classes, and templatefunctions that aid in the declaration and manipulation of iterators.</P><PRE>namespace std {struct <B><A HREF="#input_iterator_tag">input_iterator_tag</A></B>;struct <B><A HREF="#output_iterator_tag">output_iterator_tag</A></B>;struct <B><A HREF="#forward_iterator_tag">forward_iterator_tag</A></B>;struct <B><A HREF="#bidirectional_iterator_tag">bidirectional_iterator_tag</A></B>;struct <B><A HREF="#random_access_iterator_tag">random_access_iterator_tag</A></B>;        // TEMPLATE CLASSEStemplate&lt;class Category, class Ty, class Diff,    class Pointer, class Reference&gt;    struct <B><A HREF="#iterator">iterator</A></B>;template&lt;class Iter&gt;    struct <B><A HREF="#iterator_traits">iterator_traits</A></B>;template&lt;class Ty&gt;    struct <B><A HREF="#iterator_traits">iterator_traits</A></B>&lt;Ty *&gt;;template&lt;class Ty&gt;    struct <B>iterator_traits</B>&lt;const Ty *&gt;;template&lt;class RanIt&gt;    class <B><A HREF="#reverse_iterator">reverse_iterator</A></B>;template&lt;class Container&gt;    class <B><A HREF="#back_insert_iterator">back_insert_iterator</A></B>;template&lt;class Container&gt;    class <B><A HREF="#front_insert_iterator">front_insert_iterator</A></B>;template&lt;class Container&gt;    class <B><A HREF="#insert_iterator">insert_iterator</A></B>;template&lt;class Ty, class Elem, class Tr, class Diff&gt;    class <B><A HREF="#istream_iterator">istream_iterator</A></B>;template&lt;class Ty, class Elem, class Tr&gt;    class <B><A HREF="#ostream_iterator">ostream_iterator</A></B>;template&lt;class Elem, class Tr&gt;    class <B><A HREF="#istreambuf_iterator">istreambuf_iterator</A></B>;template&lt;class Elem, class Tr&gt;    class <B><A HREF="#ostreambuf_iterator">ostreambuf_iterator</A></B>;        // TEMPLATE FUNCTIONStemplate&lt;class RanIt&gt;    bool <B><A HREF="#operator==">operator==</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class Ty, class Elem, class Tr, class Diff&gt;    bool <B><A HREF="#operator==">operator==</A></B>(        const istream_iterator&lt;Ty, Elem, Tr, Diff&gt;&amp; left,        const istream_iterator&lt;Ty, Elem, Tr, Diff&gt;&amp; right);template&lt;class Elem, class Tr&gt;    bool <B><A HREF="#operator==">operator==</A></B>(        const istreambuf_iterator&lt;Elem, Tr&gt;&amp; left,        const istreambuf_iterator&lt;Elem, Tr&gt;&amp; right);template&lt;class RanIt&gt;    bool <B><A HREF="#operator!=">operator!=</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class Ty, class Elem, class Tr, class Diff&gt;    bool <B><A HREF="#operator!=">operator!=</A></B>(        const istream_iterator&lt;Ty, Elem, Tr, Diff&gt;&amp; left,        const istream_iterator&lt;Ty, Elem, Tr, Diff&gt;&amp; right);template&lt;class Elem, class Tr&gt;    bool <B><A HREF="#operator!=">operator!=</A></B>(        const istreambuf_iterator&lt;Elem, Tr&gt;&amp; left,        const istreambuf_iterator&lt;Elem, Tr&gt;&amp; right);template&lt;class RanIt&gt;    bool <B><A HREF="#operator&lt;">operator&lt;</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class RanIt&gt;    bool <B><A HREF="#operator&gt;">operator&gt;</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class RanIt&gt;    bool <B><A HREF="#operator&lt;=">operator&lt;=</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class RanIt&gt;    bool <B><A HREF="#operator&gt;=">operator&gt;=</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class RanIt&gt;    Diff <B><A HREF="#operator-">operator-</A></B>(        const reverse_iterator&lt;RanIt&gt;&amp; left,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class RanIt&gt;    reverse_iterator&lt;RanIt&gt; <B><A HREF="#operator+">operator+</A></B>(        Diff off,        const reverse_iterator&lt;RanIt&gt;&amp; right);template&lt;class Container&gt;    back_insert_iterator&lt;Container&gt; <B><A HREF="#back_inserter">back_inserter</A></B>(Container&amp; cont);template&lt;class Container&gt;    front_insert_iterator&lt;Container&gt; <B><A HREF="#front_inserter">front_inserter</A></B>(Container&amp; cont);template&lt;class Container, class Iter&gt;    insert_iterator&lt;Container&gt; <B><A HREF="#inserter">inserter</A></B>(Container&amp; cont, Iter it);template&lt;class InIt, class Diff&gt;    void <B><A HREF="#advance">advance</A></B>(InIt&amp; it, Diff off);template&lt;class Init&gt;    iterator_traits&lt;InIt&gt;::difference_type        <B><A HREF="#distance">distance</A></B>(InIt first, InIt last);    };</PRE><H2><A NAME="advance"><CODE>advance</CODE></A></H2><PRE>template&lt;class InIt, class Diff&gt;    void <B>advance</B>(InIt&amp; it, Diff off);</PRE><P>The template function effectively advances <CODE>it</CODE> byincrementing it <CODE>off</CODE> times. If <CODE>InIt</CODE> isa random-access iterator type, the function evaluates the expression<CODE>it += off</CODE>. Otherwise, it performs each incrementby evaluating <CODE>++it</CODE>. If <CODE>InIt</CODE> is aninput or forward iterator type, <CODE>off</CODE> must not be negative.</P><H2><A NAME="back_insert_iterator"><CODE>back_insert_iterator</CODE></A></H2><PRE>template&lt;class Container&gt;    class <B>back_insert_iterator</B>        : public iterator&lt;output_iterator_tag,            void, void, void, void&gt; {public:    typedef Container <B><A HREF="#back_insert_iterator::container_type">container_type</A></B>;    typedef typename Container::reference <B><A HREF="#back_insert_iterator::reference">reference</A></B>;    explicit <B><A HREF="#back_insert_iterator::back_insert_iterator">back_insert_iterator</A></B>(Container&amp; cont);    back_insert_iterator&amp;        <B><A HREF="#back_insert_iterator::operator=">operator=</A></B>(typename Container::const_reference val);    back_insert_iterator&amp; <B><A HREF="#back_insert_iterator::operator*">operator*</A></B>();    back_insert_iterator&amp; <B><A HREF="#back_insert_iterator::operator++">operator++</A></B>();    back_insert_iterator <B><A HREF="#back_insert_iterator::operator++">operator++</A></B>(int);protected:    Container *<B><A HREF="#back_insert_iterator::container">container</A></B>;    };</PRE><P>The template class describes an output iterator object.It inserts elementsinto a container of type <B><CODE>Container</CODE></B>, which it accesses viathe protected pointer object it stores called<B><CODE><A NAME="back_insert_iterator::container">container</A></CODE></B>.The container must define:</P><UL><LI>the member type <B><CODE>const_reference</CODE></B>, which is the type ofa constant reference to an element of the sequence controlled by the container</LI><LI>the member type <B><CODE>reference</CODE></B>, which is the type ofa reference to an element of the sequence controlled by the container</LI><LI>the member type <B><CODE>value_type</CODE></B>, which is the type ofan element of the sequence controlled by the container</LI><LI>the member function <CODE><B>push_back</B>(value_type val)</CODE>,which appends a new element with value <CODE>val</CODE> to the end ofthe sequence</LI></UL><H3><A NAME="back_insert_iterator::back_insert_iterator"><CODE>back_insert_iterator::back_insert_iterator</CODE></A></H3><PRE>explicit <B>back_insert_iterator</B>(Container&amp; cont);</PRE><P>The constructor initializes<CODE><A HREF="#back_insert_iterator::container">container</A></CODE>with <CODE>&amp;cont</CODE>.</P><H3><A NAME="back_insert_iterator::container_type"><CODE>back_insert_iterator::container_type</CODE></A></H3><PRE>typedef Container <B>container_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Container</CODE>.</P><H3><A NAME="back_insert_iterator::operator*"><CODE>back_insert_iterator::operator*</CODE></A></H3><PRE>back_insert_iterator&amp; <B>operator*</B>();</PRE><P>The member function returns <CODE>*this</CODE>.</P><H3><A NAME="back_insert_iterator::operator++"><CODE>back_insert_iterator::operator++</CODE></A></H3><PRE>back_insert_iterator&amp; <B>operator++</B>();back_insert_iterator <B>operator++</B>(int);</PRE><P>The member functions both return <CODE>*this</CODE>.</P><H3><A NAME="back_insert_iterator::operator="><CODE>back_insert_iterator::operator=</CODE></A></H3><PRE>back_insert_iterator&amp;    <B>operator=</B>(typename Container::const_reference val);</PRE><P>The member function evaluates<CODE><A HREF="#back_insert_iterator::container">container</A>-&gt;push_back(val)</CODE>, then returns <CODE>*this</CODE>-&gt;</P><H3><A NAME="back_insert_iterator::reference"><CODE>back_insert_iterator::reference</CODE></A></H3><PRE>typedef typename Container::reference <B>reference</B>;</PRE><P>The type describes a reference to an element of the sequencecontrolled by the associated container.</P><H2><A NAME="back_inserter"><CODE>back_inserter</CODE></A></H2><PRE>template&lt;class Container&gt;    back_insert_iterator&lt;Container&gt; <B>back_inserter</B>(Container&amp; cont);</PRE><P>The template function returns<CODE><A HREF="#back_insert_iterator::back_insert_iterator">back_insert_iterator</A>&lt;Container&gt;(cont)</CODE>.</P><H2><A NAME="bidirectional_iterator_tag"><CODE>bidirectional_iterator_tag</CODE></A></H2><PRE>struct <B>bidirectional_iterator_tag</B>    : public forward_iterator_tag {    };</PRE><P>The type is the same as<CODE>iterator&lt;Iter&gt;::<A HREF="#iterator::iterator_category">iterator_category</A></CODE>when <CODE>Iter</CODE> describes an object that can serve as abidirectional iterator.</P><H2><A NAME="distance"><CODE>distance</CODE></A></H2><PRE>template&lt;class Init&gt;    typename iterator_traits&lt;InIt&gt;::difference_type        <B>distance</B>(InIt first, InIt last);</PRE><P>The template function sets a count <CODE>N</CODE> to zero. It theneffectively advances <CODE>first</CODE>and increments <CODE>N</CODE> until <CODE>first == last</CODE>.If <CODE>InIt</CODE> isa random-access iterator type, the function evaluates the expression<CODE>N += last - first</CODE>. Otherwise, it performs each iteratorincrement by evaluating <CODE>++first</CODE>.The function returns <CODE>N</CODE>.</P><H2><A NAME="forward_iterator_tag"><CODE>forward_iterator_tag</CODE></A></H2><PRE>struct <B>forward_iterator_tag</B>    : public input_iterator_tag {    };</PRE><P>The type is the same as<CODE>iterator&lt;Iter&gt;::<A HREF="#iterator::iterator_category">iterator_category</A></CODE>when <CODE>Iter</CODE> describes an object that can serve as aforward iterator.</P><H2><A NAME="front_insert_iterator"><CODE>front_insert_iterator</CODE></A></H2><PRE>template&lt;class Container&gt;    class <B>front_insert_iterator</B>        : public iterator&lt;output_iterator_tag,            void, void, void, void&gt; {public:    typedef Container <B><A HREF="#front_insert_iterator::container_type">container_type</A></B>;    typedef typename Container::reference <B><A HREF="#front_insert_iterator::reference">reference</A></B>;    explicit <B><A HREF="#front_insert_iterator::front_insert_iterator">front_insert_iterator</A></B>(Container&amp; cont);    front_insert_iterator&amp;        <B><A HREF="#front_insert_iterator::operator=">operator=</A></B>(typename Container::const_reference val);    front_insert_iterator&amp; <B><A HREF="#front_insert_iterator::operator*">operator*</A></B>();    front_insert_iterator&amp; <B><A HREF="#front_insert_iterator::operator++">operator++</A></B>();    front_insert_iterator <B><A HREF="#front_insert_iterator::operator++">operator++</A></B>(int);protected:    Container *<B><A HREF="#front_insert_iterator::container">container</A></B>;    };</PRE><P>The template class describes an output iterator object.It inserts elementsinto a container of type <B><CODE>Container</CODE></B>, which it accesses viathe protected pointer object it stores called<B><CODE><A NAME="front_insert_iterator::container">container</A></CODE></B>.The container must define:</P><UL><LI>the member type <B><CODE>const_reference</CODE></B>, which is the type ofa constant reference to an element of the sequence controlled by the container</LI><LI>the member type <B><CODE>reference</CODE></B>, which is the type ofa reference to an element of the sequence controlled by the container</LI><LI>the member type <B><CODE>value_type</CODE></B>, which is the type ofan element of the sequence controlled by the container</LI><LI>the member function <CODE><B>push_front</B>(value_type val)</CODE>,which prepends a new element with value <CODE>val</CODE> to the beginning ofthe sequence</LI></UL>

⌨️ 快捷键说明

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