# Simple Queue

## [Implementation using Array](https://www.codingninjas.com/studio/problems/queue-using-array-or-singly-linked-list_2099908?leftPanelTab=0\&campaign=LoveBabbar_Codestudio\&utm_source=youtube\&utm_medium=affiliate\&utm_campaign=LoveBabbar_Codestudio)

```cpp
#include <bits/stdc++.h> 
class Queue {
    int *arr;
    int size;
    int qfront, rear, element;
public:
    Queue() {
        size = 1024;
        arr = new int [size];
        qfront = element = rear = 0;
    }

    /*----------------- Public Functions of Queue -----------------*/

    bool isEmpty() {
        return element == 0;
    }
    
    bool isFull() {
        return rear == size-1;
    }
    
    void enqueue(int data) {
        if(isFull())
            return ;
        
        element++; 
        arr[rear++] = data;
    }

    int dequeue() {
        if(isEmpty()) 
            return -1;

        element--;
        return arr[qfront++];
    }

    int front() {
        if(isEmpty())
            return -1;
            
        return arr[qfront];
    }
};
```
