📄 iterator.html
字号:
<H3><A NAME="front_insert_iterator::container_type"><CODE>front_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="front_insert_iterator::front_insert_iterator"><CODE>front_insert_iterator::front_insert_iterator</CODE></A></H3><PRE>explicit <B>front_insert_iterator</B>(Container& cont);</PRE><P>The constructor initializes<CODE><A HREF="#front_insert_iterator::container">container</A></CODE>with <CODE>&cont</CODE>.</P><H3><A NAME="front_insert_iterator::operator*"><CODE>front_insert_iterator::operator*</CODE></A></H3><PRE>front_insert_iterator& <B>operator*</B>();</PRE><P>The member function returns <CODE>*this</CODE>.</P><H3><A NAME="front_insert_iterator::operator++"><CODE>front_insert_iterator::operator++</CODE></A></H3><PRE>front_insert_iterator& <B>operator++</B>();front_insert_iterator <B>operator++</B>(int);</PRE><P>The member functions both return <CODE>*this</CODE>.</P><H3><A NAME="front_insert_iterator::operator="><CODE>front_insert_iterator::operator=</CODE></A></H3><PRE>front_insert_iterator& <B>operator=</B>(typename Container::const_reference val);</PRE><P>The member function evaluates<CODE><A HREF="#front_insert_iterator::container">container</A>->push_front(val)</CODE>, then returns <CODE>*this</CODE>.</P><H3><A NAME="front_insert_iterator::reference"><CODE>front_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="front_inserter"><CODE>front_inserter</CODE></A></H2><PRE>template<class Container> front_insert_iterator<Container> <B>front_inserter</B>(Container& cont);</PRE><P>The template function returns<CODE><A HREF="#front_insert_iterator::front_insert_iterator">front_insert_iterator</A><Container>(cont)</CODE>.</P><H2><A NAME="input_iterator_tag"><CODE>input_iterator_tag</CODE></A></H2><PRE>struct <B>input_iterator_tag</B> { };</PRE><P>The type is the same as<CODE>iterator<Iter>::<A HREF="#iterator::iterator_category">iterator_category</A></CODE>when <CODE>Iter</CODE> describes an object that can serve as aninput iterator.</P><H2><A NAME="insert_iterator"><CODE>insert_iterator</CODE></A></H2><PRE>template<class Container> class <B>insert_iterator</B> : public iterator<output_iterator_tag, void, void, void, void> {public: typedef Container <B><A HREF="#insert_iterator::container_type">container_type</A></B>; typedef typename Container::reference <B><A HREF="#insert_iterator::reference">reference</A></B>; <B><A HREF="#insert_iterator::insert_iterator">insert_iterator</A></B>(Container& cont, typename Container::iterator it); insert_iterator& <B><A HREF="#insert_iterator::operator=">operator=</A></B>(typename Container::const_reference val); insert_iterator& <B><A HREF="#insert_iterator::operator*">operator*</A></B>(); insert_iterator& <B><A HREF="#insert_iterator::operator++">operator++</A></B>(); insert_iterator& <B><A HREF="#insert_iterator::operator++">operator++</A></B>(int);protected: Container *<B><A HREF="#insert_iterator::container">container</A></B>; typename Container::iterator <B><A HREF="#insert_iterator::iter">iter</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="insert_iterator::container">container</A></CODE></B>.It also stores the protected iterator object, of class<CODE>Container::iterator</CODE>, called<B><CODE><A NAME="insert_iterator::iter">iter</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>iterator</CODE></B>, which is the type ofan iterator for 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>insert</B>(iterator it,value_type val)</CODE>,which inserts a new element with value <CODE>val</CODE> immediately beforethe element designated by <CODE>it</CODE> in the controlled sequence,then returns an iterator that designates the inserted element</LI></UL><H3><A NAME="insert_iterator::container_type"><CODE>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="insert_iterator::insert_iterator"><CODE>insert_iterator::insert_iterator</CODE></A></H3><PRE><B>insert_iterator</B>(Container& cont, typename Container::iterator it);</PRE><P>The constructor initializes<CODE><A HREF="#insert_iterator::container">container</A></CODE>with <CODE>&cont</CODE>, and<CODE><A HREF="#insert_iterator::iter">iter</A></CODE>with <CODE>it</CODE>.</P><H3><A NAME="insert_iterator::operator*"><CODE>insert_iterator::operator*</CODE></A></H3><PRE>insert_iterator& <B>operator*</B>();</PRE><P>The member function returns <CODE>*this</CODE>.</P><H3><A NAME="insert_iterator::operator++"><CODE>insert_iterator::operator++</CODE></A></H3><PRE>insert_iterator& <B>operator++</B>();insert_iterator& <B>operator++</B>(int);</PRE><P>The member functions both return <CODE>*this</CODE>.</P><H3><A NAME="insert_iterator::operator="><CODE>insert_iterator::operator=</CODE></A></H3><PRE>insert_iterator& <B>operator=</B>(typename Container::const_reference val);</PRE><P>The member function evaluates<CODE><A HREF="#insert_iterator::iter">iter</A> =<A HREF="#insert_iterator::container">container</A>->insert(iter, val)</CODE>, then returns <CODE>*this</CODE>.</P><H3><A NAME="insert_iterator::reference"><CODE>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="inserter"><CODE>inserter</CODE></A></H2><PRE>template<class Container, class Iter> insert_iterator<Container> <B>inserter</B>(Container& cont, Iter it);</PRE><P>The template function returns<CODE><A HREF="#insert_iterator::insert_iterator">insert_iterator</A><Container>(cont, it)</CODE>.</P><H2><A NAME="istream_iterator"><CODE>istream_iterator</CODE></A></H2><PRE>template<class Ty, class Elem = char, class Tr = char_traits> class Diff = ptrdiff_t> class <B>istream_iterator</B> : public iterator<input_iterator_tag, Ty, Diff, const Ty *, const Ty&> {public: typedef Elem <B><A HREF="#istream_iterator::char_type">char_type</A></B>; typedef Tr <B><A HREF="#istream_iterator::traits_type">traits_type</A></B>; typedef basic_istream<Elem, Tr> <B><A HREF="#istream_iterator::istream_type">istream_type</A></B>; <B><A HREF="#istream_iterator::istream_iterator">istream_iterator</A></B>(); <B><A HREF="#istream_iterator::istream_iterator">istream_iterator</A></B>(istream_type& istr); const Ty& <B><A HREF="#istream_iterator::operator*">operator*</A></B>() const; const Ty *<B><A HREF="#istream_iterator::operator->">operator-></A></B>() const; istream_iterator<Ty, Elem, Tr, Diff>& <B><A HREF="#istream_iterator::operator++">operator++</A></B>(); istream_iterator<Ty, Elem, Tr, Diff> <B><A HREF="#istream_iterator::operator++">operator++</A></B>(int); };</PRE><P>The template class describes an input iterator object.It extracts objects of class <B><CODE>Ty</CODE></B>from an <B>input stream</B>, which it accesses via an object it stores,of type pointer to<CODE>basic_istream<Elem, Tr></CODE>.After constructing or incrementing an object of class<CODE>istream_iterator</CODE> with a non-null stored pointer,the object attempts to extract and store an object of type<CODE>Ty</CODE> from the associated input stream. If the extractionfails, the object effectively replaces the stored pointer witha null pointer (thus making an end-of-sequence indicator).</P><H3><A NAME="istream_iterator::char_type"><CODE>istream_iterator::char_type</CODE></A></H3><PRE>typedef Elem <B>char_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Elem</CODE>.</P><H3><A NAME="istream_iterator::istream_iterator"><CODE>istream_iterator::istream_iterator</CODE></A></H3><PRE><B>istream_iterator</B>();<B>istream_iterator</B>(istream_type& istr);</PRE><P>The first constructor initializes the input stream pointerwith a null pointer.The second constructor initializes the input stream pointerwith <CODE>&istr</CODE>, then attempts to extract and storean object of type <CODE>Ty</CODE>.</P><H3><A NAME="istream_iterator::istream_type"><CODE>istream_iterator::istream_type</CODE></A></H3><PRE>typedef basic_istream<Elem, Tr> <B>istream_type</B>;</PRE><P>The type is a synonym for<CODE>basic_istream<Elem, Tr></CODE>.</P><H3><A NAME="istream_iterator::operator*"><CODE>istream_iterator::operator*</CODE></A></H3><PRE>const Ty& <B>operator*</B>() const;</PRE><P>The operator returns the stored object of type <CODE>Ty</CODE>.</P><H3><A NAME="istream_iterator::operator->"><CODE>istream_iterator::operator-></CODE></A></H3><PRE>const Ty *<B>operator-></B>() const;</PRE><P>The operator returns <CODE>&**this</CODE>.</P><H3><A NAME="istream_iterator::operator++"><CODE>istream_iterator::operator++</CODE></A></H3><PRE>istream_iterator<Ty, Elem, Tr, Diff>& <B>operator++</B>();istream_iterator<Ty, Elem, Tr, Diff> <B>operator++</B>(int);</PRE><P>The first operator attempts to extract and store an objectof type <CODE>Ty</CODE> from the associated input stream. The secondoperator makes a copy of the object, increments the object, thenreturns the copy.</P><H3><A NAME="istream_iterator::traits_type"><CODE>istream_iterator::traits_type</CODE></A></H3><PRE>typedef Tr <B>traits_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Tr</CODE>.</P><H2><A NAME="istreambuf_iterator"><CODE>istreambuf_iterator</CODE></A></H2><PRE>template<class Elem, class Tr = char_traits<Elem> > class <B>istreambuf_iterator</B> : public iterator<input_iterator_tag, Elem, typename Ty::off_type, Elem *, Elem&> {public: typedef Elem <B><A HREF="#istreambuf_iterator::char_type">char_type</A></B>; typedef Tr <B><A HREF="#istreambuf_iterator::traits_type">traits_type</A></B>; typedef typename Tr::int_type <B><A HREF="#istreambuf_iterator::int_type">int_type</A></B>; typedef basic_streambuf<Elem, Tr> <B><A HREF="#istreambuf_iterator::streambuf_type">streambuf_type</A></B>; typedef basic_istream<Elem, Tr> <B><A HREF="#istreambuf_iterator::istream_type">istream_type</A></B>; <B><A HREF="#istreambuf_iterator::istreambuf_iterator">istreambuf_iterator</A></B>(streambuf_type *strbuf = 0) throw(); <B><A HREF="#istreambuf_iterator::istreambuf_iterator">istreambuf_iterator</A></B>(istream_type& istr) throw(); Elem <B><A HREF="#istreambuf_iterator::operator*">operator*</A></B>() const; istreambuf_iterator& <B><A HREF="#istreambuf_iterator::operator++">operator++</A></B>(); istreambuf_iterator <B><A HREF="#istreambuf_iterator::operator++">operator++</A></B>(int); bool <B><A HREF="#istreambuf_iterator::equal">equal</A></B>(const istreambuf_iterator& right) const; };</PRE><P>The template class describes an input iterator object.It extracts elements of class <B><CODE>Elem</CODE></B>from an <B>input stream buffer</B>,which it accesses via an object it stores,of type pointer to<CODE>basic_streambuf<Elem,<B>Tr</B>></CODE>.After constructing or incrementing an object of class<CODE>istreambuf_iterator</CODE> with a non-null stored pointer,the object effectively attempts to extract and store an object of type<CODE>Elem</CODE> from the associated input stream.(The extraction may be delayed, however, until the objectis actually dereferenced or copied.) If the extractionfails, the object effectively replaces the stored pointer witha null pointer (thus making an end-of-sequence indicator).</P><H3><A NAME="istreambuf_iterator::char_type"><CODE>istreambuf_iterator::char_type</CODE></A></H3><PRE>typedef Elem <B>char_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Elem</CODE>.</P><H3><A NAME="istreambuf_iterator::equal"><CODE>istreambuf_iterator::equal</CODE></A></H3><PRE>bool <B>equal</B>(const istreambuf_iterator& right) const;</PRE><P>The member function returns true only if the stored stream bufferpointers for the object and <CODE>right</CODE> are both null pointersor are both non-null pointers.</P><H3><A NAME="istreambuf_iterator::int_type"><CODE>istreambuf_iterator::int_type</CODE></A></H3><PRE>typedef typename Tr::int_type <B>int_type</B>;</PRE><P>The type is a synonym for<CODE>Ty::int_type</CODE>.</P><H3><A NAME="istreambuf_iterator::istream_type"><CODE>istreambuf_iterator::istream_type</CODE></A></H3><PRE>typedef basic_istream<Elem, Tr> <B>istream_type</B>;</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -