Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::Queue< E > Class Template Reference

The parameterized class Queue<E> implements list-based queues. More...

#include <ogdf/basic/Queue.h>

+ Inheritance diagram for ogdf::Queue< E >:

Public Types

using const_iterator = SListConstIterator< E >
 Provides a forward iterator that can read a const element in a queue.
 
using const_reference = const E &
 Provides a reference to a const element stored in a queue for reading and performing const operations.
 
using iterator = SListIterator< E >
 Provides a forward iterator that can read or modify any element in a queue.
 
using reference = E &
 Provides a reference to an element stored in a queue.
 
using value_type = E
 Represents the data type stored in a queue element.
 

Public Member Functions

 Queue ()
 Constructs an empty queue.
 
 Queue (const Queue< E > &Q)
 Constructs a queue that is a copy of Q.
 
 Queue (Queue< E > &&Q)
 Constructs a queue containing the elements of Q (move semantics).
 
 Queue (std::initializer_list< E > initList)
 Constructs a queue and appends the elements in initList to it.
 
 ~Queue ()
 Destruction.
 
Access methods

These methods provide simple access without changing the list.

bool empty () const
 Returns true iff the queue is empty.
 
int size () const
 Returns the number of elements in the queue.
 
const_reference top () const
 Returns a reference to the front element.
 
reference top ()
 Returns a reference to the front element.
 
const_reference bottom () const
 Returns a reference to the back element.
 
reference bottom ()
 Returns a reference to the back element.
 
Iterators

These methods return forward iterators to elements in the queue.

iterator begin ()
 Returns an iterator to the first element of the queue.
 
const_iterator begin () const
 Returns a const iterator to the first element of the queue.
 
const_iterator cbegin () const
 Returns a const iterator to the first element of the queue.
 
iterator end ()
 Returns an iterator to one-past-last element of the queue.
 
const_iterator end () const
 Returns a const iterator to one-past-last element of the queue.
 
const_iterator cend () const
 Returns a const iterator to one-past-last element of the queue.
 
iterator backIterator ()
 Returns an iterator to the last element of the queue.
 
const_iterator backIterator () const
 Returns a const iterator to the last element of the queue.
 
Operators

The following operators are provided by lists.

Queue< E > & operator= (const Queue< E > &Q)
 Assignment operator.
 
Queue< E > & operator= (Queue< E > &&Q)
 Assignment operator (move semantics).
 
const SList< E > & getList () const
 Conversion to const SList.
 
Adding and removing elements

These method add elements to the list and remove elements from the list.

iterator append (const E &x)
 Adds x at the end of queue.
 
template<class... Args>
iterator emplace (Args &&... args)
 Adds a new element at the end of the queue.
 
pop ()
 Removes front element and returns it.
 
void clear ()
 Makes the queue empty.
 

Additional Inherited Members

- Private Member Functions inherited from ogdf::SList< E >
 SList ()
 Constructs an empty singly linked list.
 
 SList (const SList< E > &L)
 Constructs a singly linked list that is a copy of L.
 
 SList (SList< E > &&L)
 Constructs a singly linked list containing the elements of L (move semantics).
 
 SList (std::initializer_list< E > init)
 Constructs a singly linked list containing the elements in init.
 
int size () const
 Returns the number of elements in the list.
 
const SListPure< E > & getSListPure () const
 Conversion to const SListPure.
 
SList< E > & operator= (const SList< E > &L)
 Assignment operator.
 
SList< E > & operator= (SList< E > &&L)
 Assignment operator (move semantics).
 
bool operator== (const SList< E > &L) const
 Equality operator.
 
bool operator!= (const SList< E > &L) const
 Inequality operator.
 
SListIterator< E > pushFront (const E &x)
 Adds element x at the beginning of the list.
 
template<class... Args>
iterator emplaceFront (Args &&... args)
 Adds a new element at the beginning of the list.
 
SListIterator< E > pushBack (const E &x)
 Adds element x at the end of the list.
 
template<class... Args>
iterator emplaceBack (Args &&... args)
 Adds a new element at the end of the list.
 
SListIterator< E > insertAfter (const E &x, SListIterator< E > itBefore)
 Inserts element x after itBefore.
 
void popFront ()
 Removes the first element from the list.
 
popFrontRet ()
 Removes the first element from the list and returns it.
 
void delSucc (SListIterator< E > itBefore)
 Removes the succesor of itBefore.
 
void clear ()
 Removes all elements from the list.
 
void moveFrontToFront (SList< E > &L2)
 Moves the first element of this list to the begin of list L2.
 
void moveFrontToBack (SList< E > &L2)
 Moves the first element of this list to the end of list L2.
 
void moveFrontToSucc (SList< E > &L2, SListIterator< E > itBefore)
 Moves the first element of this list to list L2 inserted after itBefore.
 
void conc (SList< E > &L2)
 Appends L2 to this list and makes L2 empty.
 

Detailed Description

template<class E>
class ogdf::Queue< E >

The parameterized class Queue<E> implements list-based queues.

In contrast to QueuePure<E>, instances of Queue<E> store the number of elements contained in the queue.

Template Parameters
Eis the element type.

Definition at line 200 of file Queue.h.

Member Typedef Documentation

◆ const_iterator

template<class E >
using ogdf::Queue< E >::const_iterator = SListConstIterator<E>

Provides a forward iterator that can read a const element in a queue.

Definition at line 209 of file Queue.h.

◆ const_reference

template<class E >
using ogdf::Queue< E >::const_reference = const E&

Provides a reference to a const element stored in a queue for reading and performing const operations.

Definition at line 207 of file Queue.h.

◆ iterator

template<class E >
using ogdf::Queue< E >::iterator = SListIterator<E>

Provides a forward iterator that can read or modify any element in a queue.

Definition at line 211 of file Queue.h.

◆ reference

template<class E >
using ogdf::Queue< E >::reference = E&

Provides a reference to an element stored in a queue.

Definition at line 205 of file Queue.h.

◆ value_type

template<class E >
using ogdf::Queue< E >::value_type = E

Represents the data type stored in a queue element.

Definition at line 203 of file Queue.h.

Constructor & Destructor Documentation

◆ Queue() [1/4]

template<class E >
ogdf::Queue< E >::Queue ( )
inline

Constructs an empty queue.

Definition at line 214 of file Queue.h.

◆ Queue() [2/4]

template<class E >
ogdf::Queue< E >::Queue ( std::initializer_list< E >  initList)
inline

Constructs a queue and appends the elements in initList to it.

Definition at line 217 of file Queue.h.

◆ Queue() [3/4]

template<class E >
ogdf::Queue< E >::Queue ( const Queue< E > &  Q)
inline

Constructs a queue that is a copy of Q.

Definition at line 220 of file Queue.h.

◆ Queue() [4/4]

template<class E >
ogdf::Queue< E >::Queue ( Queue< E > &&  Q)
inline

Constructs a queue containing the elements of Q (move semantics).

Queue Q is empty afterwards.

Definition at line 226 of file Queue.h.

◆ ~Queue()

template<class E >
ogdf::Queue< E >::~Queue ( )
inline

Destruction.

Definition at line 229 of file Queue.h.

Member Function Documentation

◆ append()

template<class E >
iterator ogdf::Queue< E >::append ( const E &  x)
inline

Adds x at the end of queue.

Definition at line 319 of file Queue.h.

◆ backIterator() [1/2]

template<class E >
iterator ogdf::Queue< E >::backIterator ( )
inline

Returns an iterator to the last element of the queue.

Definition at line 281 of file Queue.h.

◆ backIterator() [2/2]

template<class E >
const_iterator ogdf::Queue< E >::backIterator ( ) const
inline

Returns a const iterator to the last element of the queue.

Definition at line 284 of file Queue.h.

◆ begin() [1/2]

template<class E >
iterator ogdf::Queue< E >::begin ( )
inline

Returns an iterator to the first element of the queue.

Definition at line 263 of file Queue.h.

◆ begin() [2/2]

template<class E >
const_iterator ogdf::Queue< E >::begin ( ) const
inline

Returns a const iterator to the first element of the queue.

Definition at line 266 of file Queue.h.

◆ bottom() [1/2]

template<class E >
reference ogdf::Queue< E >::bottom ( )
inline

Returns a reference to the back element.

Definition at line 253 of file Queue.h.

◆ bottom() [2/2]

template<class E >
const_reference ogdf::Queue< E >::bottom ( ) const
inline

Returns a reference to the back element.

Definition at line 250 of file Queue.h.

◆ cbegin()

template<class E >
const_iterator ogdf::Queue< E >::cbegin ( ) const
inline

Returns a const iterator to the first element of the queue.

Definition at line 269 of file Queue.h.

◆ cend()

template<class E >
const_iterator ogdf::Queue< E >::cend ( ) const
inline

Returns a const iterator to one-past-last element of the queue.

Definition at line 278 of file Queue.h.

◆ clear()

template<class E >
void ogdf::Queue< E >::clear ( )
inline

Makes the queue empty.

Definition at line 338 of file Queue.h.

◆ emplace()

template<class E >
template<class... Args>
iterator ogdf::Queue< E >::emplace ( Args &&...  args)
inline

Adds a new element at the end of the queue.

The element is constructed in-place with exactly the same arguments args as supplied to the function.

Definition at line 326 of file Queue.h.

◆ empty()

template<class E >
bool ogdf::Queue< E >::empty ( ) const
inline

Returns true iff the queue is empty.

Definition at line 238 of file Queue.h.

◆ end() [1/2]

template<class E >
iterator ogdf::Queue< E >::end ( )
inline

Returns an iterator to one-past-last element of the queue.

Definition at line 272 of file Queue.h.

◆ end() [2/2]

template<class E >
const_iterator ogdf::Queue< E >::end ( ) const
inline

Returns a const iterator to one-past-last element of the queue.

Definition at line 275 of file Queue.h.

◆ getList()

template<class E >
const SList< E > & ogdf::Queue< E >::getList ( ) const
inline

Conversion to const SList.

Definition at line 309 of file Queue.h.

◆ operator=() [1/2]

template<class E >
Queue< E > & ogdf::Queue< E >::operator= ( const Queue< E > &  Q)
inline

Assignment operator.

Definition at line 294 of file Queue.h.

◆ operator=() [2/2]

template<class E >
Queue< E > & ogdf::Queue< E >::operator= ( Queue< E > &&  Q)
inline

Assignment operator (move semantics).

Queue Q is empty afterwards.

Definition at line 303 of file Queue.h.

◆ pop()

template<class E >
E ogdf::Queue< E >::pop ( )
inline

Removes front element and returns it.

Definition at line 331 of file Queue.h.

◆ size()

template<class E >
int ogdf::Queue< E >::size ( ) const
inlinevirtual

Returns the number of elements in the queue.

Reimplemented from ogdf::SListPure< E >.

Definition at line 241 of file Queue.h.

◆ top() [1/2]

template<class E >
reference ogdf::Queue< E >::top ( )
inline

Returns a reference to the front element.

Definition at line 247 of file Queue.h.

◆ top() [2/2]

template<class E >
const_reference ogdf::Queue< E >::top ( ) const
inline

Returns a reference to the front element.

Definition at line 244 of file Queue.h.


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