queue_using_array.cpp File Reference

Implementation of Linear Queue using array. More...

`#include <array>`
`#include <iostream>`
Include dependency graph for queue_using_array.cpp:

## Classes

class | data_structures::queue_using_array::Queue_Array
| Queue_Array class containing the main data and also index of head and tail of the array. More...

## Namespaces

| data_structures
| Data Structures algorithms.
| queue_using_array
| Functions for Queue using Array implementation.

## Functions

int | main ()
| Main function. More...

## Variables

constexpr uint16_t | max_size {10}
| for io operations More...

## Detailed Description

Implementation of Linear Queue using array.

The Linear Queue is a data structure used for holding a sequence of values, which can be added to the end line (enqueue), removed from head of line (dequeue) and displayed.

### Algorithm

Values can be added by increasing the `rear` variable by 1 (which points to the end of the array), then assigning new value to `rear`'s element of the array.

Values can be removed by increasing the `front` variable by 1 (which points to the first of the array), so it cannot reached any more.

Author
  Pooja
  Farbod Ahmadian

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function.

Allows the user to add and delete values from the queue. Also allows user to display values in the queue.

Returns
  0 on exit

{
int op{0}, data{0};
data_structures::queue_using_array::Queue_Array ob;
std::cout << "\n1. enqueue(Insertion) ";
std::cout << "\n2. dequeue(Deletion)";
std::cout << "\n3. Display";
std::cout << "\n4. Exit";
while (true) {
std::cout << "\nEnter your choice ";
std::cin >> op;
if (op == 1) {
std::cout << "Enter data ";
std::cin >> data;
ob.enqueue(data);
} else if (op == 2) {
data = ob.dequeue();
std::cout << "\ndequeue element is:\t" << data;
} else if (op == 3) {
ob.display();
} else if (op == 4) {
exit(0);
} else {
std::cout << "\nWrong choice ";
}
}
return 0;
}
std::cin
std::cout
data_structures::queue_using_array::Queue_Array
Queue_Array class containing the main data and also index of head and tail of the array.
Definition: queue_using_array.cpp:43
data_structures::queue_using_array::Queue_Array::dequeue
int dequeue()
Delete element from back of the queue.
Definition: queue_using_array.cpp:75
data_structures::queue_using_array::Queue_Array::enqueue
void enqueue(const int16_t &)
Add element to the first of the queue.
Definition: queue_using_array.cpp:58
data_structures::queue_using_array::Queue_Array::display
void display() const
Show all saved data.
Definition: queue_using_array.cpp:93
std::exit
T exit(T... args)
data
int data[MAX]
test data
Definition: hash_search.cpp:24
Here is the call graph for this function:

## Variable Documentation

## max_size

constexpr uint16_t max_size {10}

constexpr

for io operations

for std::array Maximum size of the queue