https://github.com/chihebabiza/my-cpp-queue-array
A simple, template-based queue class in C++ built on top of a custom dynamic array (`clsDynamicArray`). This implementation supports core queue operations such as `push`, `pop`, `front`, and `back`, along with extended utilities like reversing the queue and inserting at custom positions.
https://github.com/chihebabiza/my-cpp-queue-array
cpp cpp-library data-structures oop programming-advices queue
Last synced: 23 days ago
JSON representation
A simple, template-based queue class in C++ built on top of a custom dynamic array (`clsDynamicArray`). This implementation supports core queue operations such as `push`, `pop`, `front`, and `back`, along with extended utilities like reversing the queue and inserting at custom positions.
- Host: GitHub
- URL: https://github.com/chihebabiza/my-cpp-queue-array
- Owner: chihebabiza
- License: mit
- Created: 2025-06-19T11:52:27.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-06-19T12:12:52.000Z (5 months ago)
- Last Synced: 2025-06-19T13:26:19.212Z (5 months ago)
- Topics: cpp, cpp-library, data-structures, oop, programming-advices, queue
- Language: C++
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Queue Implementation Using Dynamic Array in C++
A simple, template-based queue class in C++ built on top of a custom dynamic array (`clsDynamicArray`). This implementation supports core queue operations such as `push`, `pop`, `front`, and `back`, along with extended utilities like reversing the queue and inserting at custom positions.
---
## ๐ฆ Features
- FIFO Queue behavior (`push` to back, `pop` from front)
- Supports any data type via templates
- View the front and back elements
- Get size or check if queue is empty
- Insert items at the front, back, or after a specific index
- Reverse the queue
- Update items by index
- Clear all contents
---
## ๐งช Example Usage
```cpp
#include
#include "clsMyQueueArr.h"
int main() {
clsMyQueueArr myQueue;
myQueue.push(10);
myQueue.push(20);
myQueue.push(30);
cout << "Front: " << myQueue.front() << endl; // 10
cout << "Back: " << myQueue.back() << endl; // 30
myQueue.pop(); // removes 10
myQueue.Print(); // Output: 20 30
myQueue.InsertAfter(0, 25);
myQueue.UpdateItem(1, 22);
myQueue.Print(); // Output: 20 22 30
myQueue.Reverse();
myQueue.Print(); // Output: 30 22 20
}
````
---
## ๐ Public Methods
| Method | Description |
| --------------------------- | ----------------------------- |
| `push(value)` | Add item to back of the queue |
| `pop()` | Remove item from front |
| `front()` | Return front element |
| `back()` | Return back element |
| `Print()` | Display all queue elements |
| `Size()` | Return number of elements |
| `IsEmpty()` | Check if queue is empty |
| `GetItem(index)` | Get element at index |
| `UpdateItem(index, value)` | Update value at index |
| `InsertAfter(index, value)` | Insert after a given index |
| `InsertAtFront(value)` | Insert item at the front |
| `InsertAtBack(value)` | Insert item at the back |
| `Reverse()` | Reverse queue order |
| `Clear()` | Clear all elements |
---
## ๐ง Dependencies
* Requires `clsDynamicArray.h` (your custom dynamic array class)
Make sure to include both `.h` files and use `#include "clsMyQueueArr.h"` in your project.
---
## ๐ Use Case
Ideal for:
* Teaching data structures
* Simple queue logic in C++
* Practicing dynamic memory and templates
---
## ๐งพ License
This project is provided under the MIT License. See [LICENSE](LICENSE.txt) for details.