WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions DataStructures/queueimplement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include<iostream>
#include<cstdlib>
#define MAX_SIZE 10
using namespace std;
class Queue{
private:
int item[MAX_SIZE];
int rear;
int front;
public:
Queue();
void enqueue(int);
int dequeue();
int size();
void display();
bool isEmpty();
bool isFull();
};

Queue::Queue(){
rear = -1;
front = 0;
}

void Queue::enqueue(int data){
item[++rear] = data;
}
int Queue::dequeue(){
return item[front++];
}
void Queue::display(){
if(!this->isEmpty()){

for(int i=front; i<=rear; i++)
cout<<item[i]<<endl;
}else{
cout<<"Queue Underflow"<<endl;
}
}
int Queue::size(){
return (rear - front + 1);
}
bool Queue::isEmpty(){
if(front>rear){
return true;
}else{
return false;
}
}

bool Queue::isFull(){
if(this->size()>=MAX_SIZE){
return true;
}else{
return false;
}
}
int main(){


Queue queue;

//add the code that suits your needs

return 0;

}