//
// Queue.h
//
// Created by Tina Huynh on 2/8/18.
// Copyright © 2018 Tina Huynh. All rights reserved.
//
// CMPR 131 - Data Structures
#include <iostream>
using namespace std;
const int SIZE = 5;
double input;
class intQueue
{
private:
double numbers[SIZE];
int front;
int back;
public:
intQueue() { front = back = SIZE - 1 ; }
~intQueue() {}
void makeEmpty() { front = back = SIZE - 1; }
void enqueue(double input)
{
if(front == SIZE - 1)
front = 0;
back = ((back + 1) % SIZE);
numbers[back] = input;
}
void dequeue(double & input)
{
front = ((front + 1) % SIZE);
input = numbers[front];
}
bool isEmpty()
{
return (front == back);
}
bool isFull()
{
return ((back + 1) % SIZE == front);
}
void showQueue()
{
int i = front;
do {
cout << numbers[i] << " -> ";
i = ((i + 1) % SIZE);
} while(i != back);
cout << numbers[back] << " -> ";
cout << "NULL" << endl;
}
};
-----------------------------------------------------------------------------