Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
823 B
1
Indexable
Never
// Stack class to represent a stack
class Queue{
    private: 
        vector<int> arr_q;
    
    public:
        Queue(int n) {
            arr_q.resize(n);
        };

        bool isEmpty(){
            return (arr_q.size() == 0);
        }

        void enqueue(int value){
            arr_q.push_back(value);
        }

        int front(){
            return arr_q[0];
        }
    
        int rear(){
            return arr_q.back();
        }

        void dequeue(){
            if (int(arr_q.size()) == 0){
                return;
            }
            for (int i = 0; i< int(arr_q.size()) - 1; i++){
                arr_q[i] = arr_q[i+1];
            }
            arr_q.pop_back();
        }

        int size() {
            return arr_q.size();
        }


};