https://github.com/amrtamertech/clsstack_library-cpp
A C++ template-based stack library (clsMyStack) built on top of a queue and doubly linked list, offering classic LIFO operations with extra flexibility.
https://github.com/amrtamertech/clsstack_library-cpp
cpp data-structures doubly-linked-list generic-programming inheritance oop stack templates
Last synced: 7 months ago
JSON representation
A C++ template-based stack library (clsMyStack) built on top of a queue and doubly linked list, offering classic LIFO operations with extra flexibility.
- Host: GitHub
- URL: https://github.com/amrtamertech/clsstack_library-cpp
- Owner: AmrTamerTech
- Created: 2025-06-08T23:14:46.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-06-09T00:04:57.000Z (8 months ago)
- Last Synced: 2025-06-09T00:24:54.679Z (8 months ago)
- Topics: cpp, data-structures, doubly-linked-list, generic-programming, inheritance, oop, stack, templates
- Language: C++
- Homepage:
- Size: 25.1 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 📌 clsStack_Library-cpp
A reusable and extensible C++ stack implementation (`clsMyStack`) built using a doubly linked list via inheritance from a queue class. This generic class supports core stack operations along with additional list-based manipulations.
---
## 🌟 Overview
The `clsMyStack` class extends `clsMyQueue` and leverages a custom `clsDblLinkedList` for efficient memory usage and flexible data handling. It implements **Last-In-First-Out (LIFO)** behavior and is templated to work with any data type.
---
## 🚀 Features
### ✅ Basic Stack Operations:
- `Push(T value)` → Adds a new element to the top of the stack.
- `Top()` → Returns the top (most recently added) element.
- `Bottom()` → Returns the bottom (least recently added) element.
- `Pop()` → Removes the top element (inherited from `clsMyQueue`).
- `Size()` → Returns number of elements.
- `IsEmpty()` → Checks if the stack is empty.
- `Clear()` → Clears all stack elements.
- `Print()` → Prints all elements in stack order.
### ✨ Advanced (Inherited) List Operations:
- `GetItem(index)`
- `UpdateItem(index, newValue)`
- `InsertAfter(index, value)`
- `InsertAtBack(value)` – Useful for queue-style operations.
- `Reverse()` – Reverses the entire stack.
- `InsertAtFront(value)` – Used by `Push()` to maintain LIFO.
---
## 🛠Technologies Used
- **Language**: C++
- **Data Structure**: Doubly Linked List
- **Concepts**: Templates, Inheritance, OOP, Dynamic Memory
---
## 📚 Learning Outcomes
✅Implementing custom data structures with inheritance
✅Using doubly linked lists in C++
✅Applying generic programming with templates
✅Managing memory with pointer-based collections
---
## 🔧 How to Run
1. **Clone the repository:**
```bash
git clone https://github.com/your-username/clsStack_Library-cpp.git
cd clsStack_Library-cpp
```
2. **Build your test file (e.g. main.cpp):**
```bash
g++ main.cpp -o stackApp
./stackApp
```
3. **Include in your project:**
```bash
#include "clsMyStack.h"
#include "clsMyQueue.h"
#include "clsDblLinkedList.h"
```