Queue





This lab will consist of creating a circular queue
it is a template class 

the size of the queue will be passed into the constructor

test mains and a Makefile have been provided for you, complete the Queue implementation

be sure to log the start and end of all functions
do not alter any of the main files

your output should match the examples EXACTLY without any alterations to the provided mains.
File: Queue.h 

#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"






template <class T>
class Queue
{
	private:
		T * data;
		unsigned int front_index;
		unsigned int back_index;
		unsigned int capacity;

	public:

		int  size()
		{
			//if front_index less than back index
			//then size is 
			//back_index - front_index;
			// else
			//capacity - front_index + back_index;
		}



		Queue(unsigned int requested_capacity = 5 )
		{
			// set capacity to requested_capacity +1 and set data to a new array of type T size of requested_capacity +1
			// we want to make our array one space larger than the requested  capacity 
			// so if 5 is passed to the constructor make the capacity 6, if 10 is passed in make the capacity 11
			// this makes the logic to test for full and empty a lot simpler
			// set front_index and back_index to 0
		}

		~Queue()
		{

			// clean up the array pointed to by data
			LOG(INFO) << "Start " <<  __PRETTY_FUNCTION__ << endl;
			delete[]  data;
			LOG(INFO) << "End " <<  __PRETTY_FUNCTION__ << endl;

		}


		bool  empty()
		{
			// return a bool value indicating if the Queue is empty
			// empty is when front_index == back_index
		}


		// Check if the Queue is currently full
		bool  full()
		{
			// return a bool value indicating if the Queue is full
			// if full  back_index moved forward one space will equal front_index....
		}



		// Add an element to the top of the Queue
		bool  enQueue(T elem)
		{
			// if the Queue is full return false
			// insert the value elem to the array at the position of back_index
			// move the back_index one space forward (be sure to mod with capacity)
			// return true
		}



		// "Remove" the element at the front of the Queue
		bool  deQueue()
		{
			// if the Queue is empty return false
			// otherwise
			// move the front_index one space forward,  be sure to mod with capacity
			// return true
		}




		// Retrieve the value at the top of the Queue but do not delete it
		T  peekFront()
		{
			// if the queue is empty throw a the message "cannot peekFront() on and empty queue"
			// return the value at the top of the Queue , data[front_index]
		}


		string  ToString()
		{

			LOG(INFO) << "Start " <<  __PRETTY_FUNCTION__ << endl;
			string return_value="";
			ostringstream oss;
			oss << boolalpha << endl
				<< "front_index:"     << front_index << endl
				<< "back_index: " << back_index << endl
				<< "capacity:"      << capacity -1  << endl  // rememeber we made our array one space bigger that we can acctually use
				<< "empty(): "	 << empty() << endl
				<< "full(): "    << full() << endl
				<< "memory usage " << ( sizeof(capacity) + sizeof(front_index) + sizeof(back_index) + sizeof(data) + ( capacity * sizeof(T)) )<< endl;
			// notice the loop here that we can use
			for (unsigned int loop =  front_index; loop != back_index ; loop = (loop+1)%capacity   )
			{
				int position = loop;
				oss << "data["<< position <<"]: address: " << (void*) (data+position) << " value: " <<   data[position] << endl;

			}

			return_value = oss.str();
			LOG(INFO) << "End " <<  __PRETTY_FUNCTION__ << endl;
			LOG(INFO) << "Returning: " << return_value << endl ;
			return return_value;
		}




		// end of Class
};