Queue_Array class containing the main data and also index of head and tail of the array.
More...
|
void | enqueue (const int16_t &) |
| Add element to the first of the queue.
|
|
int | dequeue () |
| Delete element from back of the queue.
|
|
void | display () const |
| Show all saved data.
|
|
|
int8_t | front {-1} |
| Index of head of the array.
|
|
int8_t | rear {-1} |
| Index of tail of the array.
|
|
std::array< int16_t, max_size > | arr {} |
| All stored data.
|
|
Queue_Array class containing the main data and also index of head and tail of the array.
Definition at line 44 of file queue_using_array.cpp.
◆ dequeue()
int data_structures::queue_using_array::Queue_Array::dequeue |
( |
| ) |
|
Delete element from back of the queue.
Remove element that is located at the first of the queue.
- Returns
- data that is deleted if queue is not empty
Definition at line 76 of file queue_using_array.cpp.
76 {
77 int8_t d{0};
79 std::cout << "\nstack is empty ";
80 return 0;
84 } else {
86 }
87
88 return d;
89}
int8_t front
Index of head of the array.
int8_t rear
Index of tail of the array.
std::array< int16_t, max_size > arr
All stored data.
◆ display()
void data_structures::queue_using_array::Queue_Array::display |
( |
| ) |
const |
Show all saved data.
Utility function to show all elements in the queue.
Definition at line 94 of file queue_using_array.cpp.
94 {
96 std::cout << "\nStack is empty";
97 } else {
98 for (int16_t i{
front}; i <=
rear; ++i) std::cout <<
arr.at(i) <<
" ";
99 }
100}
◆ enqueue()
void data_structures::queue_using_array::Queue_Array::enqueue |
( |
const int16_t & | ele | ) |
|
Add element to the first of the queue.
Adds new element to the end of the queue.
- Parameters
-
ele | to be added to the end of the queue |
Definition at line 59 of file queue_using_array.cpp.
59 {
61 std::cout << "\nStack is full";
69 }
70}
◆ arr
std::array<int16_t, max_size> data_structures::queue_using_array::Queue_Array::arr {} |
|
private |
◆ front
int8_t data_structures::queue_using_array::Queue_Array::front {-1} |
|
private |
◆ rear
int8_t data_structures::queue_using_array::Queue_Array::rear {-1} |
|
private |
The documentation for this class was generated from the following file: