📄 deq_0575.htm
字号:
<HTML><HEAD><TITLE>7.1 The deque Data Abstraction</TITLE></HEAD><BODY><A HREF="ug1.htm"><IMG SRC="images/banner.gif"></A><BR><A HREF="deq_4164.htm"><IMG SRC="images/prev.gif"></A><A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="deq_2889.htm"><IMG SRC="images/next.gif"></A><BR><STRONG>Click on the banner to return to the user guide home page.</STRONG><H2>7.1 The deque Data Abstraction</H2><P>The name "deque" is short for "double-ended queue," and is pronounced like "deck." Traditionally, the term is used to describe any data structure that permits both insertions and removals from either the front or the back of a collection. The <A HREF="../stdlibcr/deq_4164.htm"><B><I>deque</I></B></A> container class permits this, as well as much more. In fact, the capabilities of the <B><I>deque</I></B> data structure are almost a union of those provided by the <A HREF="../stdlibcr/vec_0251.htm"><B><I>vector</I></B></A> and <A HREF="../stdlibcr/lis_3222.htm"><B><I>list</I></B></A> classes.</P><UL><LI>Like a vector, the deque is an indexed collection. Values can be accessed by subscript, using the position within the collection as a key. (A capability not provided by the list class).</LI><LI>Like a list, values can be efficiently added either to the front or to the back of a deque. (A capability provided only in part by the vector class).</LI><LI>As with both the list and vector classes, insertions can be made into the middle of the sequence held by a deque. Such insertion operations are not as efficient as with a list, but slightly more efficient that they are in a vector.</LI></UL><P>In short, a deque can often be used both in situations that require a vector and in those that call for a list. Often, the use of a deque in place of either a vector or a list will result in faster programs. To determine which data structure should be used, you can refer to the set of questions described in <A HREF="sel_2116.htm">Section 4.2</A></P><A NAME="7.1.1"><H3>7.1.1 Include Files</H3></A><P>The <SAMP>deque</SAMP> header file must appear in all programs that use the <A HREF="../stdlibcr/deq_4164.htm"><B><I>deque</I></B></A> data type.</P><PRE># include <deque></PRE><HR><A HREF="deq_4164.htm"><IMG SRC="images/prev.gif"></A> <A HREF="booktoc1.htm"><IMG SRC="images/toc.gif"></A><A HREF="tindex1.htm"><IMG SRC="images/tindex.gif"></A><A HREF="deq_2889.htm"><IMG SRC="images/next.gif"></A><P>©Copyright 1996, Rogue Wave Software, Inc.</P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -