Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#ifndef QUEUE_H
#define QUEUE_H
#include <exception>
#include <memory>
class Queue
{
private:
const int maxSize;
int numValues;
std::unique_ptr<char[]> queue;
public:
class Full: public std::exception
{
public:
virtual const char* what() const throw();
};
class Empty: public std::exception
{
public:
virtual const char* what() const throw();
};
/** Initialise the queue, maxSize is the maximum number of
values that can be stored in the queue at any time **/
Queue( const int _maxSize );
~Queue();
/** Returns the number of values currently stored in the
queue **/
int num_items() const;
/** Add value to the front of the queue, raises Queue::Full
exception is queue is full **/
void push( char value );
/** Returns the value currently stored at the front of the
queue, raises Queue::Empty exception is queue is
empty **/
char front() const;
/** Returns the value currently stored at the back of the
queue, raises Queue.Empty exception if the queue is
empty **/
char back() const;
/** Removes and returns the value currently stored at the
front of the queue, raises Queue::Empty exception is queue
is empty **/
char pop();
};
#endif