a double ended queue with its least item in \( O( 1 ) \) amortized time
More...
#include <ADS/queue/MinDeque.h>
|
| using | Item = T |
| | the type of the items
|
|
| | MinDeque (C less=C()) |
| | the empty deque, ordered by less
|
| bool | empty (void) const |
| | true if there is no item
|
| std::size_t | size (void) const |
| | the number \( n \) of items
|
| void | push_front (const T &x) |
| | \( x \) at the front
|
| void | push_back (const T &x) |
| | \( x \) at the back
|
| T | pop_front (void) |
| | removes the item at the front and returns it
|
| T | pop_back (void) |
| | removes the item at the back and returns it, the mirror of pop_front()
|
| const T & | front (void) const |
| | the item at the front
|
| const T & | back (void) const |
| | the item at the back
|
| const T & | min (void) const |
| | the least item, the lesser of the minima of the two stacks
|
| void | clear (void) |
| | removes all the items
|
template<class T, class C = std::less<>>
class ADS::MinDeque< T, C >
a double ended queue with its least item in \( O( 1 ) \) amortized time
◆ Item
template<class T, class C = std::less<>>
◆ MinDeque()
template<class T, class C = std::less<>>
the empty deque, ordered by less
◆ back()
template<class T, class C = std::less<>>
the item at the back
- Precondition
- the deque is not empty
◆ clear()
template<class T, class C = std::less<>>
◆ empty()
template<class T, class C = std::less<>>
◆ front()
template<class T, class C = std::less<>>
the item at the front
- Precondition
- the deque is not empty
◆ min()
template<class T, class C = std::less<>>
the least item, the lesser of the minima of the two stacks
- Precondition
- the deque is not empty
◆ pop_back()
template<class T, class C = std::less<>>
removes the item at the back and returns it, the mirror of pop_front()
- Precondition
- the deque is not empty
- Postcondition
- one item less
◆ pop_front()
template<class T, class C = std::less<>>
removes the item at the front and returns it
In pseudocode (Morin, exercise 3.16), \( F \) and \( B \) the two stacks:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{popFront}() \cr
2 & \quad \textbf{if}\ F = \emptyset\ \textbf{then}\ \mathrm{deal}( B ,
F ) \cr
3 & \quad \textbf{return}\ \mathrm{pop}( F )
\end{array}}
\]
- Precondition
- the deque is not empty
- Postcondition
- one item less
◆ push_back()
template<class T, class C = std::less<>>
◆ push_front()
template<class T, class C = std::less<>>
◆ size()
template<class T, class C = std::less<>>
the number \( n \) of items
The documentation for this class was generated from the following file: