ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Dequeue< T > Class Template Reference

a DEQUEUE on a bidirectional list with pointers More...

#include <ADS/queue/Dequeue.h>

Public types

using Item = T
 the type of the items
using value_type = T
 the type of the items
using size_type = std::size_t
 the type of the sizes
using difference_type = std::ptrdiff_t
 the type of the distances
using reference = T &
 a reference to an item
using const_reference = const T &
 a constant reference to an item
using iterator = typename List< T >::iterator
 the iterator on the items
using const_iterator = typename List< T >::const_iterator
 the iterator on the constant items
using reverse_iterator = typename List< T >::reverse_iterator
 the iterator on the items, backwards
using const_reverse_iterator = typename List< T >::const_reverse_iterator
 the iterator on the constant items, backwards

Public member functions

bool empty (void) const
 true if there is no item
void insertHead (const T &v)
 puts \( v \) at the head, insert( head() , v ) of the list
void insertTail (const T &v)
 puts \( v \) at the tail, before the sentinel of the list
T removeHead (void)
 removes the item at the head and returns it
T removeTail (void)
 removes the item at the tail and returns it
const T & head (void) const
 the item at the head
const T & tail (void) const
 the item at the tail
iterator begin (void)
 the iterator on the first item
iterator end (void)
 the iterator past the last item
const_iterator begin (void) const
 the constant iterator on the first item
const_iterator end (void) const
 the constant iterator past the last item
const_iterator cbegin (void) const
 the constant iterator on the first item
const_iterator cend (void) const
 the constant iterator past the last item
reverse_iterator rbegin (void)
 the iterator on the last item, backwards
reverse_iterator rend (void)
 the iterator before the first item, backwards
const_reverse_iterator rbegin (void) const
 the constant iterator on the last item, backwards
const_reverse_iterator rend (void) const
 the constant iterator before the first item, backwards
void push_back (const T &v)
 insertTail(), for std::back_inserter
void push_front (const T &v)
 insertHead(), for std::front_inserter

Detailed description

template<class T>
class ADS::Dequeue< T >

a DEQUEUE on a bidirectional list with pointers

Member typedef documentation

◆ const_iterator

template<class T>
using ADS::Dequeue< T >::const_iterator = typename List< T >::const_iterator

the iterator on the constant items

◆ const_reference

template<class T>
using ADS::Dequeue< T >::const_reference = const T &

a constant reference to an item

◆ const_reverse_iterator

template<class T>
using ADS::Dequeue< T >::const_reverse_iterator = typename List< T >::const_reverse_iterator

the iterator on the constant items, backwards

◆ difference_type

template<class T>
using ADS::Dequeue< T >::difference_type = std::ptrdiff_t

the type of the distances

◆ Item

template<class T>
using ADS::Dequeue< T >::Item = T

the type of the items

◆ iterator

template<class T>
using ADS::Dequeue< T >::iterator = typename List< T >::iterator

the iterator on the items

◆ reference

template<class T>
using ADS::Dequeue< T >::reference = T &

a reference to an item

◆ reverse_iterator

template<class T>
using ADS::Dequeue< T >::reverse_iterator = typename List< T >::reverse_iterator

the iterator on the items, backwards

◆ size_type

template<class T>
using ADS::Dequeue< T >::size_type = std::size_t

the type of the sizes

◆ value_type

template<class T>
using ADS::Dequeue< T >::value_type = T

the type of the items

Member function documentation

◆ begin() [1/2]

template<class T>
iterator ADS::Dequeue< T >::begin ( void )
inlinenodiscard

the iterator on the first item

◆ begin() [2/2]

template<class T>
const_iterator ADS::Dequeue< T >::begin ( void ) const
inlinenodiscard

the constant iterator on the first item

◆ cbegin()

template<class T>
const_iterator ADS::Dequeue< T >::cbegin ( void ) const
inlinenodiscard

the constant iterator on the first item

◆ cend()

template<class T>
const_iterator ADS::Dequeue< T >::cend ( void ) const
inlinenodiscard

the constant iterator past the last item

◆ empty()

template<class T>
bool ADS::Dequeue< T >::empty ( void ) const
nodiscard

true if there is no item

◆ end() [1/2]

template<class T>
iterator ADS::Dequeue< T >::end ( void )
inlinenodiscard

the iterator past the last item

◆ end() [2/2]

template<class T>
const_iterator ADS::Dequeue< T >::end ( void ) const
inlinenodiscard

the constant iterator past the last item

◆ head()

template<class T>
const T & ADS::Dequeue< T >::head ( void ) const
nodiscard

the item at the head

Precondition
the dequeue is not empty

◆ insertHead()

template<class T>
void ADS::Dequeue< T >::insertHead ( const T & v)

puts \( v \) at the head, insert( head() , v ) of the list

In pseudocode (exercise 4.9), \( L \) the list:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{insertHead}( v ) \cr 2 & \quad L.\mathrm{insert}( L.\mathrm{head}() , v ) \end{array}} \]

Postcondition
the dequeue is not empty

◆ insertTail()

template<class T>
void ADS::Dequeue< T >::insertTail ( const T & v)

puts \( v \) at the tail, before the sentinel of the list

In pseudocode (exercise 4.9):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{insertTail}( v ) \cr 2 & \quad L.\mathrm{insert}( L.\mathrm{next}( L.\mathrm{tail}() ) , v ) \end{array}} \]

Postcondition
the dequeue is not empty

◆ push_back()

template<class T>
void ADS::Dequeue< T >::push_back ( const T & v)
inline

insertTail(), for std::back_inserter

◆ push_front()

template<class T>
void ADS::Dequeue< T >::push_front ( const T & v)
inline

insertHead(), for std::front_inserter

◆ rbegin() [1/2]

template<class T>
reverse_iterator ADS::Dequeue< T >::rbegin ( void )
inlinenodiscard

the iterator on the last item, backwards

◆ rbegin() [2/2]

template<class T>
const_reverse_iterator ADS::Dequeue< T >::rbegin ( void ) const
inlinenodiscard

the constant iterator on the last item, backwards

◆ removeHead()

template<class T>
T ADS::Dequeue< T >::removeHead ( void )

removes the item at the head and returns it

In pseudocode (exercise 4.9):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{removeHead}() \cr 2 & \quad p \gets L.\mathrm{head}();\ v \gets L.\mathrm{read}( p ); \ L.\mathrm{remove}( p );\ \textbf{return}\ v \end{array}} \]

Precondition
the dequeue is not empty

◆ removeTail()

template<class T>
T ADS::Dequeue< T >::removeTail ( void )

removes the item at the tail and returns it

In pseudocode (exercise 4.9):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{removeTail}() \cr 2 & \quad p \gets L.\mathrm{tail}();\ v \gets L.\mathrm{read}( p ); \ L.\mathrm{remove}( p );\ \textbf{return}\ v \end{array}} \]

Precondition
the dequeue is not empty

◆ rend() [1/2]

template<class T>
reverse_iterator ADS::Dequeue< T >::rend ( void )
inlinenodiscard

the iterator before the first item, backwards

◆ rend() [2/2]

template<class T>
const_reverse_iterator ADS::Dequeue< T >::rend ( void ) const
inlinenodiscard

the constant iterator before the first item, backwards

◆ tail()

template<class T>
const T & ADS::Dequeue< T >::tail ( void ) const
nodiscard

the item at the tail

Precondition
the dequeue is not empty

The documentation for this class was generated from the following file: