📄 deque.htm
字号:
<html>
<head>
<title> The deque Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="dequeban.gif">
<pre>
<font size=5>Class Name</font> deque
<font size=5>Header File</font> <deque>
<font size=5>Classification</font> Container
</pre>
<a href="deque.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<i>None</i>
<h1>Methods</h1>
<pre>
<a href="list.htm#assign1">template <class InputIterator> void assign(InputIterator First, InputIterator Last)</a><br>
<a href="list.htm#assign2">template <class Size, class U> void assign(Size n, const U& u = U())</a><br>
<a href="vector.htm#at">reference at(size_type N)</a><br>
<a href="vector.htm#at">const_reference at(size_type N) const</a><br>
<a href="vector.htm#back">reference back()</a><br>
<a href="vector.htm#back">const_reference back() const</a><br>
<a href="common.htm#begin">iterator begin()</a><br>
<a href="common.htm#begin">const_iterator begin() const</a><br>
<a href="list.htm#clear">void clear()</a><br>
<a href="deque.htm#deque1">explicit deque(const Allocator& = Allocator())</a><br>
<a href="deque.htm#deque2">explicit deque(size_type N, const T& value = T(), const Allocator& X= Allocator())</a><br>
<a href="deque.htm#deque3">template <class InputIterator>deque(InputIterator First, InputIterator Last,const Allocator& = Allocator())</a><br>
<a href="deque.htm#deque4">deque(const deque<T,Allocator>& X)</a><br>
<a href="deque.htm#deque5">~deque()</a><br>
<a href="common.htm#empty"><bool empty() const</a><br>
<a href="common.htm#end">iterator end()</a><br>
<a href="common.htm#end">const_iterator end() const</a><br>
<a href="sequence.htm#erase1">iterator erase(iterator Pos)</a><br>
<a href="sequence.htm#erase2">iterator erase(iterator First, iterator Last)</a><br>
<a href="vector.htm#front">reference front()</a><br>
<a href="vector.htm#front">const_reference front() const</a><br>
<a href="list.htm#getallocator">allocator_type get_allocator() const</a><br>
<a href="sequence.htm#insert1">iterator insert(iterator position, const T& x = T())</a><br>
<a href="sequence.htm#insert2">void insert(iterator position, size_type n, const T& x)</a><br>
<a href="sequence.htm#insert3">template <class InputIterator> void insert(iterator Pos, InputIterator First, InputIterator Last)</a><br>
<a href="common.htm#maxsize">size_type max_size() const</a><br>
<a href="vector.htm#popback">void pop_back()</a><br>
<a href="vector.htm#pushback">void push_back(const T& X)</a><br>
<a href="common.htm#rbegin">reverse_iterator rbegin()</a><br>
<a href="common.htm#rbegin">const_reverse_iterator rbegin() const</a><br>
<a href="common.htm#rend">reverse_iterator rend()</a><br>
<a href="list.htm#resize">void resize(size_type Sz, T C = T())</a><br>
<a href="common.htm#rend">const_reverse_iterator rend() const</a><br>
<a href="common.htm#size">size_type size() const</a><br>
<a href="deque.htm#swap">void swap(deque<T,Allocator> &X)</a><br>
</pre>
<h2><a name=operator.htm">Operators</h2></a>
deque<T,Allocator>& operator=(const deque<T,Allocator>& X);
reference operator[](size_type N);
const_reference operator[](size_type N) const;
<a href="deque.htm#example"><h2>Example</h2></a><br>
<a name="desc"><h3>Description</h3></a>
<p>
A Deque (pronounced deck ) is a queue with the restricted access relieved a little.
A queue is said to have restricted access because if there are a group of objects stored in
a queue they may only be dequeued one at a time from the front of the queue, and may only
be enqueued one at a time into the rear of the queue. The deque relaxes this constraint
somewhat. In a deque objects may be enqueued into either the rear of the queue or the front
of the queue. Likewise objects may be dequeued from either the front of the queue or the rear
of the queue. Unlike the priority queues the deques have no inherant sort order. In addition to
being able to place remove objects from the front or rear of the queue, the standard C++
deque class allows direct access to objects through the use of the subscript [] operator.
</p>
<hr>
<pre>
<a name="swap">Method swap()</a>
Access Public
Classification Modifier
Syntax void swap(deque<T,Allocator>& X)
Parameters X is the deque that will be swapped.
Return X is the Deque to be swapped.
</pre>
<h3>Description</h3>
<p>
The swap() method swaps the contents of the current vector with deque X.
</p>
<hr>
<pre>
<a name="deque1">Method deque()</a>
Access Public
Classification Constructor
Syntax explicit deque(const Allocator& X = Allocator())
Parameters X is a allocator object.
Return None.
</pre>
<h3>Description</h3>
<p>
The deque() method constructs an empty deque container.
</p>
<hr>
<pre>
<a name="deque2">Method deque()</a>
Access Public
Classification Constructor
Syntax explicit deque(size_type N, const T& Value = T(),const Allocator& X = Allocator())
Parameters X is a allocator object. N is the number of objects that have been initialized
with value that will be inserted into the deque.
Return None.
</pre>
<h3>Description</h3>
<p>
The deque() method constructs a deque that contains N objects that have been initialized
to value.
</p>
<hr>
<pre>
<a name="deque3">Method deque()</a>
Access Public
Classification Constructor
Syntax template <class InputIterator>deque(InputIterator First, InputIterator Last,const Allocator &X = Allocator())
Parameters The range [First,Last) will be used to construct the deque object. X is an allocator object.
Return None.
</pre>
<h3>Description</h3>
<p>
The deque() method constructs a deque that contains copies of the objects that are located in the
range [First,Last).
</p>
<hr>
<pre>
<a name="deque4">Method deque()</a>
Access Public
Classification Constructor
Syntax deque(const deque<T,Allocator>& X)
Parameters X is a deque used to construct a new deque.
Return None.
</pre>
<h3>Description</h3>
<p>
The deque() method constructs a deque that contains a copy of deque X.
</p>
<hr>
<pre>
<a name="deque5">Method deque()</a>
Access Public
Classification Destructor
Syntax ~deque()
Parameters None.
Return None.
</pre>
<h3>Description</h3>
<p>
The ~deque() method destructs a deque object.
</p>
<hr>
<a name="example"></a>
<img src="lego.gif">
<pre>
// This program demonstrates some of the uses
// of the random access iterators, the subscript[]
// operators, and with the deque container
#include <deque>
#include <iostream>
using namespace std;
void main(void)
{
deque<double> Dq(10,5);
deque<double>::iterator P = Dq.begin();
P = P + 5;
*P = 25;
P = P - 3;
*P = 15;
P++;
*P = 30;
P += 5;
*P = 125;
Dq[0] = 0.005;
Dq[9] = 500.05;
int N = Dq.size();
P = Dq.end();
P--;
while(N)
{
cout << "Dq : " << N << " " << *P << endl;
P--;
N--;
}
}
</pre>
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -