📄 list.html
字号:
<P>The member function never throws an exception.</P><H3><CODE><A NAME="list::remove_if">list::remove_if</A></CODE></H3><PRE>templace<class Pr1> void <B>remove_if</B>(Pr1 pred);</PRE><P>The member function removes from the controlled sequenceall elements, designated by the iterator <CODE>where</CODE>, for which<CODE>pred(*where)</CODE> is true.</P><P>An exception occurs only if <CODE>pred</CODE> throws an exception.In that case, the controlled sequence is left in an unspecified stateand the exception is rethrown.</P><H3><CODE><A NAME="list::rend">list::rend</A></CODE></H3><PRE>const_reverse_iterator <B>rend</B>() const;reverse_iterator <B>rend</B>();</PRE><P>The member function returns a reverse bidirectionaliterator that points at thefirst element of the sequence (or just beyond the end of an emptysequence). Hence, it designates the end of the reverse sequence.</P><H3><CODE><A NAME="list::resize">list::resize</A></CODE></H3><PRE>void <B>resize</B>(size_type newsize);void <B>resize</B>(size_type newsize, Ty val);</PRE><P>The member functions both ensure that<CODE><A HREF="#list::size">size</A>()</CODE> henceforthreturns <CODE>newsize</CODE>. If it must make the controlled sequence longer,the first member functionappends elements with value <CODE>Ty()</CODE>, while the second member functionappends elements with value <CODE>val</CODE>.To make the controlled sequence shorter, both member functions call<CODE><A HREF="#list::erase">erase</A>(begin() + newsize, end())</CODE>.</P><H3><CODE><A NAME="list::reverse">list::reverse</A></CODE></H3><PRE>void <B>reverse</B>();</PRE><P>The member function reverses the order in which elements appearin the controlled sequence.</P><H3><CODE><A NAME="list::reverse_iterator">list::reverse_iterator</A></CODE></H3><PRE>typedef reverse_iterator<iterator> <B>reverse_iterator</B>;</PRE><P>The type describes an object that can serve as a reversebidirectional iterator for the controlled sequence.</P><H3><CODE><A NAME="list::size">list::size</A></CODE></H3><PRE>size_type <B>size</B>() const;</PRE><P>The member function returns the length of the controlled sequence.</P><H3><CODE><A NAME="list::size_type">list::size_type</A></CODE></H3><PRE>typedef T2 <B>size_type</B>;</PRE><P>The unsigned integer type describes an object that can represent thelength of any controlled sequence. It is described here as asynonym for the implementation-defined type <CODE>T2</CODE>.</P><H3><CODE><A NAME="list::sort">list::sort</A></CODE></H3><PRE>void <B>sort</B>();template<class Pr3> void <B>sort</B>(Pr3 pred);</PRE><P>Both member functions order the elements in the controlledsequence by a predicate, described below.</P><P>For the iterators <CODE>Pi</CODE> and <CODE>Pj</CODE>designating elements at positions <CODE>I</CODE>and <CODE>J</CODE>, the first member function imposes theorder <CODE>!(*Pj < *Pi)</CODE> whenever <CODE>I < J</CODE>.(The elements are sorted in <I>ascending</I> order.)The member template function imposes the order<CODE>!pred(*Pj, *Pi)</CODE> whenever <CODE>I < J</CODE>.No ordered pairs of elements in the original controlled sequenceare reversed in the resulting controlled sequence.(The sort is stable.)</P><P>An exception occurs only if <CODE>pred</CODE> throws an exception.In that case, the controlled sequence is left in unspecified orderand the exception is rethrown.</P><H3><CODE><A NAME="list::splice">list::splice</A></CODE></H3><PRE>void <B>splice</B>(iterator where, list& right);void <B>splice</B>(iterator where, list& right, iterator first);void <B>splice</B>(iterator where, list& right, iterator first, iterator last);</PRE><P>The first member function inserts the sequence controlledby <CODE>right</CODE> before the element in the controlled sequencepointed to by <CODE>where</CODE>. It also removes all elements from<CODE>right</CODE>. (<CODE>&right</CODE> must not equal <CODE>this</CODE>.)</P><P>The second member function removes the element pointed to by<CODE>first</CODE> in the sequence controlled by <CODE>right</CODE> andinserts it before the element in the controlled sequencepointed to by <CODE>where</CODE>. (If <CODE>where == first || where == ++first</CODE>,no change occurs.)</P><P>The third member function inserts the subrangedesignated by <CODE>[first, last)</CODE> from the sequencecontrolled by <CODE>right</CODE>before the element in the controlled sequence pointed to by <CODE>where</CODE>.It also removes the original subrange from the sequence controlledby <CODE>right</CODE>. (If <CODE>&right == this</CODE>,the range <CODE>[first, last)</CODE> must not include the elementpointed to by <CODE>where</CODE>.)</P><P>If the third member function inserts<CODE>N</CODE> elements, and <CODE>&right != this</CODE>, an object of class<CODE><A HREF="#list::iterator">iterator</A></CODE> isincremented <CODE>N</CODE> times.For all <CODE>splice</CODE> member functions, If<CODE><A HREF="#list::get_allocator">get_allocator</A>()== str.get_allocator()</CODE>, no exception occurs.Otherwise, a copy and a destructor call alsooccur for each inserted element.</P><P>Only iterators or references that designate spliced elements become<B><A NAME="invalid list iterators">invalid</A></B>.</P><H3><CODE><A NAME="list::swap">list::swap</A></CODE></H3><PRE>void <B>swap</B>(list& right);</PRE><P>The member function swaps the controlled sequences between<CODE>*this</CODE> and <CODE>where</CODE>. If<CODE><A HREF="#list::get_allocator">get_allocator</A>()== where.get_allocator()</CODE>, it does so in constant time,it throws no exceptions, and it invalidates no references, pointers,or iterators that designate elements in the two controlled sequences.Otherwise, it performs a number of element assignments and constructor callsproportional to the number of elements in the two controlled sequences.</P><H3><CODE><A NAME="list::unique">list::unique</A></CODE></H3><PRE>void <B>unique</B>();template<class Pr2> void <B><A HREF="#list::unique">unique</A></B>(Pr2 pred);</PRE><P>The first member function removes from the controlled sequenceevery element that compares equal to its preceding element.For the iterators <CODE>Pi</CODE> and <CODE>Pj</CODE>designating elements at positions <CODE>I</CODE>and <CODE>J</CODE>, the second member function removes everyelement for which <CODE>I + 1 == J && pred(*Pi, *Pj)</CODE>.</P><P>For a controlled sequence of length <CODE>N</CODE>(> 0), the predicate <CODE>pred(*Pi, *Pj)</CODE>is evaluated <CODE>N - 1</CODE> times.</P><P>An exception occurs only if <CODE>pred</CODE> throws an exception.In that case, the controlled sequence is left in an unspecified stateand the exception is rethrown.</P><H3><CODE><A NAME="list::value_type">list::value_type</A></CODE></H3><PRE>typedef typename Alloc::value_type <B>value_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Ty</CODE>.</P><H2><A NAME="operator!="><CODE>operator!=</CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator!=</B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function returns <CODE>!(left == right)</CODE>.</P><H2><A NAME="operator=="><CODE>operator==</CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator==</B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function overloads <CODE>operator==</CODE> to comparetwo objects of template class<A HREF="#list"><CODE>list</CODE></A>. The function returns<CODE>left.<A HREF="#list::size">size</A>() == right.size() &&<A HREF="algorith.html#equal">equal</A>(left.<A HREF="#list::begin">begin</A>(), left.<A HREF="#list::end">end</A>(), right.begin())</CODE>.</P><H2><A NAME="operator<"><CODE>operator<</CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator<</B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function overloads <CODE>operator<</CODE> to comparetwo objects of template class<A HREF="#list"><CODE>list</CODE></A>. The function returns<CODE><A HREF="algorith.html#lexicographical_compare">lexicographical_compare</A>(left.<A HREF="#list::begin">begin</A>(), left.<A HREF="#list::end">end</A>(), right.begin(), right.end())</CODE>.</P><H2><A NAME="operator<="><CODE>operator<=</CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator<=</B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function returns <CODE>!(right < left)</CODE>.</P><H2><A NAME="operator>"><CODE>operator></CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator></B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function returns <CODE>right < left</CODE>.</P><H2><A NAME="operator>="><CODE>operator>=</CODE></A></H2><PRE>template<class Ty, class Alloc> bool <B>operator>=</B>( const list <Ty, Alloc>& left, const list <Ty, Alloc>& right);</PRE><P>The template function returns <CODE>!(left < right)</CODE>.</P><H2><A NAME="swap"><CODE>swap</CODE></A></H2><PRE>template<class Ty, class Alloc> void <B>swap</B>( list <Ty, Alloc>& left, list <Ty, Alloc>& right);</PRE><P>The template function executes<CODE>left.<A HREF="#list::swap">swap</A>(right)</CODE>.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> © 1994-2002by P.J. Plauger. Portions derived from work<A HREF="crit_hp.html">copyright</A> © 1994by Hewlett-Packard Company. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -