Data Structures in C++
Public Member Functions
DynamicQueue< T > Class Template Reference

Queue implementation with dynamic memory allocation. More...

#include <DynamicQueue.hpp>

Inheritance diagram for DynamicQueue< T >:
Collaboration diagram for DynamicQueue< T >:

Public Member Functions

string getName ()
 Provides the name of the data structure as a string representation. More...
 
 DynamicQueue ()
 
 DynamicQueue (int data[])
 create the structure and populate it with the data from the array More...
 
void enqueue (T val)
 Add an element to the end of the queue. More...
 
dequeue ()
 Remove an element from the queue. More...
 
peek ()
 See the first value from the queue, without removing it. More...
 
int getSize ()
 Outputs the number of elements stored in the structure. More...
 
bool isEmpty ()
 Check whether the structure is empty. More...
 
bool isFull ()
 Check whether the structure is full. More...
 
- Public Member Functions inherited from ProtectedLinkedList< T >
 ProtectedLinkedList ()
 
 ~ProtectedLinkedList ()
 

Additional Inherited Members

- Protected Member Functions inherited from ProtectedLinkedList< T >
Node< T > * getNode (int index)
 
 ProtectedLinkedList (const T data[])
 create the structure and populate it with the data from the array More...
 
Node< T > * getFirst () const
 
Node< T > * getLast () const
 
virtual void insert (const T val)
 Insert an element at the end of the list. More...
 
virtual void insert (const T val, const int index)
 Insert an element at the specified position in the list. More...
 
virtual T remove (const int index)
 Remove an element from the list. More...
 
virtual T get (const int index)
 Get the element at the specified position in the list, without removing. More...
 
virtual Iterator< T > iterator ()
 Creates an Iterator, an object that allows the sequential access of values in a Linked List without the search overhead. More...
 

Detailed Description

template<class T>
class DynamicQueue< T >

Queue implementation with dynamic memory allocation.

Author
Douglas De Rizzo Meneghetti (dougl.nosp@m.asri.nosp@m.zzom@.nosp@m.gmai.nosp@m.l.com)
Date
2017-6-14Queue implementation with dynamic memory allocation. This queue extends a ProtectedLinkedList in order to gain dynamic memory allocation powers.
Template Parameters
TThe type of object the data structure will contain

Definition at line 18 of file DynamicQueue.hpp.

Constructor & Destructor Documentation

◆ DynamicQueue() [1/2]

template<class T>
DynamicQueue< T >::DynamicQueue ( )
inlineexplicit

Definition at line 22 of file DynamicQueue.hpp.

22 {}

◆ DynamicQueue() [2/2]

template<class T>
DynamicQueue< T >::DynamicQueue ( int  data[])
inlineexplicit

create the structure and populate it with the data from the array

Parameters
dataan array with data with which the structure will be initialized

Definition at line 26 of file DynamicQueue.hpp.

26 : ProtectedLinkedList<T>(data) {}
Doubly-linked list implementation with dynamic memory allocation.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf =======
>>>>>>> master

Member Function Documentation

◆ dequeue()

template<class T>
T DynamicQueue< T >::dequeue ( )
inlinevirtual

Remove an element from the queue.

Returns
the value that is being removed

Implements Queue< T >.

Definition at line 32 of file DynamicQueue.hpp.

32  {
33  if (isEmpty())
34  throw std::out_of_range("The queue is empty");
36  }
bool isEmpty()
Check whether the structure is empty.
virtual T remove(const int index)
Remove an element from the list.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ enqueue()

template<class T>
void DynamicQueue< T >::enqueue ( val)
inlinevirtual

Add an element to the end of the queue.

Parameters
valthe value to be added to the queue

Implements Queue< T >.

Definition at line 28 of file DynamicQueue.hpp.

28  {
30  }
Doubly-linked list implementation with dynamic memory allocation.
virtual void insert(const T val)
Insert an element at the end of the list.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ getName()

template<class T>
string DynamicQueue< T >::getName ( )
inlinevirtual

Provides the name of the data structure as a string representation.

Returns
name of the data structure

Reimplemented from ProtectedLinkedList< T >.

Definition at line 20 of file DynamicQueue.hpp.

20 { return "Dynamic Queue"; }

◆ getSize()

template<class T>
int DynamicQueue< T >::getSize ( )
inlinevirtual

Outputs the number of elements stored in the structure.

Returns
number of elements stored in the structure

Reimplemented from ProtectedLinkedList< T >.

Definition at line 44 of file DynamicQueue.hpp.

int getSize()
Outputs the number of elements stored in the structure.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ isEmpty()

template<class T>
bool DynamicQueue< T >::isEmpty ( )
inlinevirtual

Check whether the structure is empty.

Returns
True if empty, otherwise false

Reimplemented from ProtectedLinkedList< T >.

Definition at line 46 of file DynamicQueue.hpp.

bool isEmpty()
Check whether the structure is empty.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ isFull()

template<class T>
bool DynamicQueue< T >::isFull ( )
inlinevirtual

Check whether the structure is full.

Returns
True if full, otherwise false

Reimplemented from ProtectedLinkedList< T >.

Definition at line 48 of file DynamicQueue.hpp.

bool isFull()
Check whether the structure is full.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ peek()

template<class T>
T DynamicQueue< T >::peek ( )
inlinevirtual

See the first value from the queue, without removing it.

Returns
The first value on the queue

Implements Queue< T >.

Definition at line 38 of file DynamicQueue.hpp.

38  {
39  if (isEmpty())
40  throw std::out_of_range("The queue is empty");
42  }
bool isEmpty()
Check whether the structure is empty.
virtual T get(const int index)
Get the element at the specified position in the list, without removing.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master
The documentation for this class was generated from the following file: