# Algorithms_in_C++: Queue Class Reference

Loading...
Searching...
No Matches
Queue Class Reference
Collaboration diagram for Queue:
[legend]

## Public Member Functions

void | createNode (int val)
void | enqueue (int val)
void | dequeue ()
void | traverse ()

## Public Attributes

node * | t [100]
int | front
int | rear

## Private Attributes

node * | front =nullptr
node * | rear =nullptr

## Member Function Documentation

## createNode()

void Queue::createNode | ( | int | val | ) |

inline

{
auto* nn = new node;
nn->data = val;
nn->next = nullptr;
front = nn;
rear = nn;
}
node
Definition: avltree.cpp:13

## dequeue()

void Queue::dequeue | ( |  | ) |

inline

{
node* n;
n = front;
if (n) {
front = front->next;
delete n;
}
}

## enqueue()

void Queue::enqueue | ( | int | val | ) |

inline

{
if (front == nullptr || rear == nullptr) {
createNode(val);
}
else {
node* nn;
nn = new node;
nn->data = val;
rear->next = nn;
nn->next = front;
rear = nn;
}
}

## traverse()

void Queue::traverse | ( |  | ) |

inline

{
node* ptr;
ptr = front;
if (ptr) {
do {
std::cout << ptr->data << " ";
ptr = ptr->next;
} while (ptr != rear->next);
std::cout << front->data << std::endl;
}
}
std::cout
std::endl
T endl(T... args)

The documentation for this class was generated from the following files:

- data_structures/binary_search_tree.cpp
- data_structures/circular_queue_using_linked_list.cpp