Queue using linked list in C++
Implementation of queue data structure using single linked list in C++. Github: sourcecode/queueusinglinkedlist.h #ifndef _QUEUE_USING_LINKEDLIST_H #define _QUEUE_USING_LINKEDLIST_H #include <iostream> using namespace std; /* Quque using linked list */ template <typename T> class queuelist { linkedList<T>* queue; //linkedlist int size; //size of the quque public: //constructor queuelist():size(0) { queue = new linkedList<T>(); //create linkedlist with the desired data type } //add the element void enqueue(T elem) { //add the element at end of the list queue->addlast(elem); } //remove the element from the queue T dequeue() { //if queue is empty, return the null if (isEmpty()) { cout << "empty list" << endl; return 0; } else { //get the first element from the queue T data = queue->peekfirst(); //remove the first element from the queue queue->removefirst(); return data; } ...