?? slist.html
字號:
<P>All additions to the controlled sequence occur as if by calls to<CODE><A HREF="#slist::insert">insert</A></CODE>, which is theonly member function that calls the constructor<CODE>T(const T&)</CODE>. If such an expression throwsan exception, the container object inserts no new elements and rethrowsthe exception. Thus, an object of template class <CODE>slist</CODE>is left in a known state when such exceptions occur.</P><H3><CODE><A NAME="slist::allocator_type">slist::allocator_type</A></CODE></H3><PRE>typedef A <B>allocator_type</B>;</PRE> <P>The type is a synonym for the template parameter <CODE>A</CODE>.</P> <H3><CODE><A NAME="slist::assign">slist::assign</A></CODE></H3><PRE>template<class InIt> void <B>assign</B>(InIt first, InIt last);void <B>assign</B>(size_type n, const T& x);</PRE><P>If <CODE>InIt</CODE> is an integer type, the first memberfunction behaves the same as <CODE>assign((size_type)first, (T)last)</CODE>.Otherwise, thefirst member function replaces the sequencecontrolled by <CODE>*this</CODE> with the sequence<CODE>[first, last)</CODE>, which must <I>not</I> overlapthe initial controlled sequence.The second member function replaces the sequencecontrolled by <CODE>*this</CODE> with a repetition of <CODE>n</CODE>elements of value <CODE>x</CODE>.</P><H3><CODE><A NAME="slist::back">slist::back</A></CODE></H3><PRE>reference <B>back</B>();const_reference <B>back</B>() const;</PRE><P>The member function returns a reference to the last element of thecontrolled sequence, which must be non-empty.</P><H3><CODE><A NAME="slist::begin">slist::begin</A></CODE></H3><PRE>const_iterator <B>begin</B>() const;iterator <B>begin</B>();</PRE><P>The member function returns a forward iterator that points atthe first element of the sequence (or just beyond the end of an emptysequence).</P> <H3><CODE><A NAME="slist::clear">slist::clear</A></CODE></H3><PRE>void <B>clear</B>();</PRE> <P>The member function calls<CODE><A HREF="#slist::erase">erase</A>(<A HREF="#slist::begin">begin</A>(),<A HREF="#slist::end">end</A>())</CODE>.</P> <H3><CODE><A NAME="slist::const_iterator">slist::const_iterator</A></CODE></H3><PRE>typedef T1 <B>const_iterator</B>;</PRE><P>The type describes an object that can serve as a constantforward iterator for the controlled sequence.It is described here as asynonym for the implementation-defined type <CODE>T1</CODE>.</P> <H3><CODE><A NAME="slist::const_pointer">slist::const_pointer</A></CODE></H3><PRE>typedef typename A::const_pointer <B>const_pointer</B>;</PRE><P>The type describes an object that can serve as a constant pointerto an element of the controlled sequence.</P><H3><CODE><A NAME="slist::const_reference">slist::const_reference</A></CODE></H3><PRE>typedef typename A::const_reference <B>const_reference</B>;</PRE><P>The type describes an object that can serve as a constant referenceto an element of the controlled sequence.</P><H3><CODE><A NAME="slist::difference_type">slist::difference_type</A></CODE></H3><PRE>typedef T3 <B>difference_type</B>;</PRE> <P>The signed integer type describes an object that can represent thedifference between the addresses of any two elements in the controlledsequence. It is described here as asynonym for the implementation-defined type <CODE>T3</CODE>.</P> <H3><CODE><A NAME="slist::empty">slist::empty</A></CODE></H3><PRE>bool <B>empty</B>() const;</PRE> <P>The member function returns true for an empty controlled sequence.</P><H3><CODE><A NAME="slist::end">slist::end</A></CODE></H3><PRE>const_iterator <B>end</B>() const;iterator <B>end</B>();</PRE> <P>The member function returns a forward iterator that pointsjust beyond the end of the sequence.</P> <H3><CODE><A NAME="slist::erase">slist::erase</A></CODE></H3><PRE>iterator <B>erase</B>(iterator it);iterator <B>erase</B>(iterator first, iterator last);</PRE><P>The first member function removes the element of the controlledsequence pointed to by <CODE>it</CODE>. The second member functionremoves the elements of the controlled sequencein the range <CODE>[first, last)</CODE>.Both return an iterator that designates the first element remainingbeyond any elements removed, or<CODE><A HREF="#slist::end">end</A>()</CODE> if no such element exists.</P><P>Erasing <CODE>N</CODE> elements causes<CODE>N</CODE> destructor calls.<A HREF="#slist reallocation">Reallocation</A> occurs,so iterators and references become<A HREF="#invalid slist iterators">invalid</A> for the erasedelements and iterators become invalid for any remaining elementimmediately beyond an erased element.</P><P>The member functions never throw an exception.</P><H3><CODE><A NAME="slist::front">slist::front</A></CODE></H3><PRE>reference <B>front</B>();const_reference <B>front</B>() const;</PRE><P>The member function returns a reference to the first element of thecontrolled sequence, which must be non-empty.</P><H3><CODE><A NAME="slist::get_allocator">slist::get_allocator</A></CODE></H3><PRE>A <B>get_allocator</B>() const;</PRE> <P>The member function returns the stored<A HREF="memory.html#allocator object">allocator object</A>.</P> <H3><CODE><A NAME="slist::insert">slist::insert</A></CODE></H3><PRE>iterator <B>insert</B>(iterator it, const T& x);void <B>insert</B>(iterator it, size_type n, const T& x);template<class InIt> void <B>insert</B>(iterator it, InIt first, InIt last);</PRE> <P>Each of the member functions inserts, before the element pointed toby <CODE>it</CODE> in the controlled sequence, a sequencespecified by the remaining operands.The first member function insertsa single element with value <CODE>x</CODE> and returns an iteratorthat designates the newly inserted element. The second member functioninserts a repetition of <CODE>n</CODE> elements of value <CODE>x</CODE>.</P><P>If <CODE>InIt</CODE> is an integer type, the last memberfunction behaves the same as <CODE>insert(it, (size_type)first, (T)last)</CODE>.Otherwise, the last member function inserts the sequence<CODE>[first, last)</CODE>, which must <I>not</I> overlapthe initial controlled sequence.</P><P>Inserting <CODE>N</CODE> elements causes <CODE>N</CODE>constructor calls.<A HREF="#slist reallocation">Reallocation</A> occurs,so iterators become<A HREF="#invalid slist iterators">invalid for any elementthat was immediately beyond <CODE>it</CODE></A>.</P><P>If an exception is thrown during theinsertion of one or more elements, the container is left unalteredand the exception is rethrown.</P><H3><CODE><A NAME="slist::iterator">slist::iterator</A></CODE></H3><PRE>typedef T0 <B>iterator</B>;</PRE> <P>The type describes an object that can serve as a forwarditerator for the controlled sequence.It is described here as asynonym for the implementation-defined type <CODE>T0</CODE>.</P> <H3><CODE><A NAME="slist::max_size">slist::max_size</A></CODE></H3><PRE>size_type <B>max_size</B>() const;</PRE> <P>The member function returns the length of the longest sequence thatthe object can control.</P> <H3><CODE><A NAME="slist::merge">slist::merge</A></CODE></H3><PRE>void <B>merge</B>(slist& x);template<class Pred> void <B>merge</B>(slist& x, Pred pr);</PRE><P>Both member functions remove all elements from the sequencecontrolled by <CODE>x</CODE> and insert them in the controlledsequence. Both sequences must be<A HREF="lib_stl.html#sequence ordering">ordered by</A> the same predicate,described below. The resulting sequence is also ordered by thatpredicate.</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 second member function imposes the order<CODE>!pr(*Pj, *Pi)</CODE> whenever <CODE>i < j</CODE>.</P><P>No pairs of elements in the original controlled sequenceare reversed in the resulting controlled sequence. If a pairof elements in the resulting controlled sequence compares equal(<CODE>!(*Pi < *Pj) && !(*Pj < *Pi)</CODE>),an element from the original controlled sequence appears beforean element from the sequence controlled by <CODE>x</CODE>.</P><P>An exception occurs only if <CODE>pr</CODE> throws an exception.In that case, the controlled sequence is left in unspecified orderand the exception is rethrown.</P><H3><CODE><A NAME="slist::pointer">slist::pointer</A></CODE></H3><PRE>typedef typename A::pointer <B>pointer</B>;</PRE> <P>The type describes an object that can serve as a pointer to anelement of the controlled sequence.</P> <H3><CODE><A NAME="slist::pop_back">slist::pop_back</A></CODE></H3><PRE>void <B>pop_back</B>();</PRE><P>The member function removes the last element of thecontrolled sequence, which must be non-empty.This operation takes time proportional to the number of elementsin the controlled sequence (linear time complexity).</P><P>The member function never throws an exception.</P><H3><CODE><A NAME="slist::pop_front">slist::pop_front</A></CODE></H3><PRE>void <B>pop_front</B>();</PRE><P>The member function removes the first element of thecontrolled sequence, which must be non-empty.</P><P>The member function never throws an exception.</P><H3><CODE><A NAME="slist::previous">slist::previous</A></CODE></H3><PRE>iterator <B>previous</B>(const_iterator it);const_iterator <B>previous</B>(const_iterator it) const;</PRE>
?? 快捷鍵說明
復制代碼
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -