Deque

The <#8663#>Queue<#8663#> and <#8664#>Stack<#8664#> classes are derived from the abstract base class <#8665#>Deque<#8665#>, which inherits privately from <#8666#>List<#8666#> to screen out all operations that allow access to elements other than the first element. <#8667#>Deque<#8667#> pointers can be used to point to either <#8668#>Stack<#8668#> or <#8669#>Queue<#8669#> objects. This flexibility is helpful in algorithms such as maximum flow, in which the algorithm user might wish to select at run time which storage protocal to use. Several <#8670#>List<#8670#> operations are allowed through the filter for use by <#8671#>Stacks<#8671#> and <#8672#>Queues<#8672#>. Those accessible through <#8673#>Deque<#8673#> pointers are listed below. Note that the 61 constructors for <#8674#>Stacks<#8674#> and <#8675#>Queues<#8675#> are more restricted than those of other <#8676#>Container<#8676#> classes. Copies are constructed only from like objects, not arbitrary <#8677#>Containers<#8677#>. <#8700#>

<#8702#>
Item front()
<#8702#>
<#8707#>

Returns the head of the <#8786#>Deque<#8786#> without removing it. <#8796#>O(1)<#8796#>


<#8707#>


<#8700#>

<#8712#>

<#8714#>
void insert(Item& e) = 0;
<#8714#>
<#8719#>

Inserts <#8721#>e<#8721#> at the front of the list if a <#8787#>Stack<#8787#> is referenced (<#8798#>O(1)<#8798#>) and at the end of the list if a <#8788#>Queue<#8788#> is (<#8800#>O(n)<#8800#>).


<#8719#>


<#8712#>

<#8725#>

<#8727#>
Item get()
<#8727#>
<#8732#>

Removes the element at the front of the list and returns it. <#8802#>O(1)<#8802#>


<#8732#>


<#8725#>

<#8737#>

<#8739#>
Bool emptyQ()
<#8739#>
<#8744#>

Is the <#8789#>Deque<#8789#> empty? <#8804#>O(1)<#8804#>


<#8744#>


<#8737#>

<#8749#>

<#8751#>
Bool sortedQ() const
<#8751#>
<#8756#>

Return FALSE. <#8806#>O(1)<#8806#>.


<#8756#>


<#8749#>

<#8761#>

<#8763#>
void clear()
<#8763#>
<#8768#>

Remove all the elements from the <#8790#>Deque<#8790#>. <#8808#>O(n)<#8808#>


<#8768#>


<#8761#>

<#8773#>

<#8775#>
void display()
<#8775#>
<#8780#>

Produce a human-readable display of the data structure. <#8810#>O(n)<#8810#>


<#8780#>


<#8773#>