📄 deque.html
字号:
<PRE>const_iterator <B>end</B>() const;iterator <B>end</B>();</PRE><P>The member function returns a random-access iterator that pointsjust beyond the end of the sequence.</P><H3><CODE><A NAME="deque::erase">deque::erase</A></CODE></H3><PRE>iterator <B>erase</B>(iterator where);iterator <B>erase</B>(iterator first, iterator last);</PRE><P>The first member function removes the element of the controlledsequence pointed to by <CODE>where</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="#deque::end">end</A>()</CODE> if no such element exists.</P><P>Removing <CODE>N</CODE> elements causes <CODE>N</CODE> destructor callsand an assignment for each of the elements between the insertionpoint and the nearer end of the sequence.Removing an element at either end<A HREF="#invalid deque iterators">invalidates</A> only iterators andreferences that designate the erased elements. Otherwise,erasing an element invalidates all iterators and references.</P><P>The member functions throw an exception only if a copy operationthrows an exception.</P><H3><CODE><A NAME="deque::front">deque::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="deque::get_allocator">deque::get_allocator</A></CODE></H3><PRE>Alloc <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="deque::insert">deque::insert</A></CODE></H3><PRE>iterator <B>insert</B>(iterator where, const Ty& val);void <B>insert</B>(iterator where, size_type count, const Ty& val);template<class InIt> void <B>insert</B>(iterator where, InIt first, InIt last);</PRE><P>Each of the member functions inserts, before the element pointed toby <CODE>where</CODE> in the controlled sequence, a sequencespecified by the remaining operands.The first member function insertsa single element with value <CODE>val</CODE> and returns an iteratorthat designates the newly inserted element.The second member functioninserts a repetition of <CODE>count</CODE> elements of value <CODE>val</CODE>.<P>If <CODE>InIt</CODE> is an integer type, the last memberfunction behaves the same as <CODE>insert(where, (size_type)first, (Ty)last)</CODE>.Otherwise, thelast member function inserts the sequence<CODE>[first, last)</CODE>, which must <I>not</I> overlapthe initial controlled sequence.</P><P>When inserting a single element, the number ofelement copies is linear in the number of elements between the insertionpoint and the nearer end of the sequence. When inserting a single elementat either end of the sequence, the amortized number of element copiesis constant. When inserting <CODE>N</CODE> elements,the number of element copies is linear in<CODE>N</CODE> plus the number of elements between the insertionpoint and the nearer end of the sequence -- except when the template memberis specialized for <CODE>InIt</CODE> an input or forward iterator, whichbehaves like <CODE>N</CODE> single insertions.Inserting an element at either end<A HREF="#invalid deque iterators">invalidates</A> all iterators,but no references, that designate existing elements. Otherwise,inserting an element invalidates all iterators and references.</P><P>If an exception is thrown during theinsertion of one or more elements, and the exception is not thrown whilecopying an element, the container is left unalteredand the exception is rethrown.</P><H3><CODE><A NAME="deque::iterator">deque::iterator</A></CODE></H3><PRE>typedef T0 <B>iterator</B>;</PRE><P>The type describes an object that can serve as a random-accessiterator for the controlled sequence.It is described here as asynonym for the implementation-defined type <CODE>T0</CODE>.</P><H3><CODE><A NAME="deque::max_size">deque::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="deque::operator[]">deque::operator[]</A></CODE></H3><PRE>const_reference <B>operator[]</B>(size_type pos) const;reference <B>operator[]</B>(size_type pos);</PRE><P>The member function returns a reference to the element of thecontrolled sequence at position <CODE>pos</CODE>. If that position isinvalid, the behavior is undefined.</P><H3><CODE><A NAME="deque::pointer">deque::pointer</A></CODE></H3><PRE>typedef typename Alloc::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="deque::pop_back">deque::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.Removing the element<A HREF="#invalid deque iterators">invalidates</A> only iterators andreferences that designate the erased element.</P><P>The member function never throws an exception.</P><H3><CODE><A NAME="deque::pop_front">deque::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.Removing the element<A HREF="#invalid deque iterators">invalidates</A> only iterators andreferences that designate the erased element.</P><P>The member function never throws an exception.</P><H3><CODE><A NAME="deque::push_back">deque::push_back</A></CODE></H3><PRE>void <B>push_back</B>(const Ty& val);</PRE><P>The member function inserts an element with value <CODE>val</CODE>at the end of the controlled sequence. Inserting the element<A HREF="#invalid deque iterators">invalidates</A> all iterators,but no references, to existing elements.</P><P>If an exception is thrown, the container is left unalteredand the exception is rethrown.</P><H3><CODE><A NAME="deque::push_front">deque::push_front</A></CODE></H3><PRE>void <B>push_front</B>(const Ty& val);</PRE><P>The member function inserts an element with value <CODE>val</CODE>at the beginning of the controlled sequence. Inserting the element<A HREF="#invalid deque iterators">invalidates</A> all iterators,but no references, to existing elements.</P><P>If an exception is thrown, the container is left unalteredand the exception is rethrown.</P><H3><CODE><A NAME="deque::rbegin">deque::rbegin</A></CODE></H3><PRE>const_reverse_iterator <B>rbegin</B>() const;reverse_iterator <B>rbegin</B>();</PRE><P>The member function returns a reverse iterator that points justbeyond the end of the controlled sequence. Hence, it designates thebeginning of the reverse sequence.</P><H3><CODE><A NAME="deque::reference">deque::reference</A></CODE></H3><PRE>typedef typename Alloc::reference <B>reference</B>;</PRE><P>The type describes an object that can serve as a reference to anelement of the controlled sequence.</P><H3><CODE><A NAME="deque::rend">deque::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 iterator 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="deque::resize">deque::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="#deque::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="#deque::erase">erase</A>(begin() + newsize, end())</CODE>.</P><H3><CODE><A NAME="deque::reverse_iterator">deque::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 reverserandom-access iterator for the controlled sequence.</P><H3><CODE><A NAME="deque::size">deque::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="deque::size_type">deque::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="deque::swap">deque::swap</A></CODE></H3><PRE>void <B>swap</B>(deque& right);</PRE><P>The member function swaps the controlled sequences between<CODE>*this</CODE> and <CODE>right</CODE>. If<CODE><A HREF="#deque::get_allocator">get_allocator</A>()== right.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="deque::value_type">deque::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 deque <Ty, Alloc>& left, const deque <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 deque <Ty, Alloc>& left, const deque <Ty, Alloc>& right);</PRE><P>The template function overloads <CODE>operator==</CODE> to comparetwo objects of template class<A HREF="#deque"><CODE>deque</CODE></A>. The function returns<CODE>left.<A HREF="#deque::size">size</A>() == right.size() &&<A HREF="algorith.html#equal">equal</A>(left.<A HREF="#deque::begin">begin</A>(), left.<A HREF="#deque::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 deque <Ty, Alloc>& left, const deque <Ty, Alloc>& right);</PRE><P>The template function overloads <CODE>operator<</CODE> to comparetwo objects of template class<A HREF="#deque"><CODE>deque</CODE></A>. The function returns<CODE><A HREF="algorith.html#lexicographical_compare">lexicographical_compare</A>(left.<A HREF="#deque::begin">begin</A>(), left.<A HREF="#deque::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 deque <Ty, Alloc>& left, const deque <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 deque <Ty, Alloc>& left, const deque <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 deque <Ty, Alloc>& left, const deque <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>( deque <Ty, Alloc>& left, deque <Ty, Alloc>& right);</PRE><P>The template function executes<CODE>left.<A HREF="#deque::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 + -