An open API service indexing awesome lists of open source software.

https://github.com/amrtamertech/clsstack_with_dynamic_array_library-cpp

A C++ template-based stack implementation built using a custom dynamic array class (clsDynamicArray) and extended from a custom queue structure (clsMyQueueArr). This project demonstrates how to implement a flexible stack structure with additional features such as element insertion, updating, reversing, and random access, beyond traditional LIFO beh
https://github.com/amrtamertech/clsstack_with_dynamic_array_library-cpp

cpp data-structures dynamic-array generic-programming inheritance oop stack templates

Last synced: 8 days ago
JSON representation

A C++ template-based stack implementation built using a custom dynamic array class (clsDynamicArray) and extended from a custom queue structure (clsMyQueueArr). This project demonstrates how to implement a flexible stack structure with additional features such as element insertion, updating, reversing, and random access, beyond traditional LIFO beh

Awesome Lists containing this project

README

        

# ๐Ÿ“Œ Stack Implementation (`clsMyStackArr`) โšก

A C++ template-based stack implementation built on top of a dynamic array-based queue (`clsMyQueueArr`). This class simulates LIFO (Last In, First Out) behavior using `clsDynamicArray`. ๐Ÿš€

---

## ๐ŸŒŸ Project Overview

The `clsMyStackArr` class extends the `clsMyQueueArr` class and adapts its behavior to act as a **stack**. By overriding the `Push()` function to insert elements at the front of the dynamic array, it enables typical stack operations like `Push`, `Top`, and `Bottom`, while maintaining access to other dynamic features.

This implementation uses **C++ templates**, making it type-generic and suitable for any data type.

---

## ๐Ÿ”น Core Functionalities:

- ๐Ÿš€ Push: Insert elements in LIFO order
- ๐Ÿ” Top & Bottom: Access the first and last items
- ๐Ÿ“ Stack Size, Print, and Clear
- ๐Ÿ”„ Reverse and Modify Internal Elements (Inherited)
- โœจ All the power of `clsMyQueueArr` + stack-specific control

---

## โœจ Features

### ๐Ÿ”น Stack-Specific Operations
- `Push(Value)` โ€“ Adds an element to the **top** (front) of the stack.
- `Top()` โ€“ Returns the **top** element of the stack.
- `Bottom()` โ€“ Returns the **bottom** element of the stack (oldest pushed).

### ๐Ÿ”น Inherited Functionalities from `clsMyQueueArr`
- `Pop()` โ€“ Removes the top (front) element.
- `Size()` โ€“ Returns number of elements.
- `IsEmpty()` โ€“ Checks if stack is empty.
- `Print()` โ€“ Displays all stack elements.
- `Reverse()` โ€“ Reverses stack order.
- `GetItem(Index)`, `UpdateItem(Index, NewValue)`
- `InsertAfter(Index, Value)`, `InsertAtBack(Value)`
- `Clear()` โ€“ Empties the stack completely.

---

## ๐Ÿš€ How It Works

### ๐Ÿ”น LIFO Behavior
- `Push()` inserts at the **beginning** of the internal array.
- `Pop()` removes from the **beginning** (top of stack).

### ๐Ÿ”น Element Access
- `Top()` = first element = most recently pushed.
- `Bottom()` = last element = earliest pushed.

---

## โš™๏ธ Technologies Used

- **Language**: C++
- **Templates**: Enables generic stack support
- **Inheritance**: Leverages `clsMyQueueArr`
- **Dynamic Array**: Efficient memory use via `clsDynamicArray`

---

## ๐ŸŽฏ Learning Outcomes

โœ… Understanding of stack behavior using arrays
โœ… C++ templates and inheritance
โœ… Custom dynamic data structures
โœ… Using queue logic to implement a stack

---

## ๐Ÿ“œ License

This project is open-source. Feel free to use and extend it! ๐Ÿš€

---

## ๐Ÿค Contributing

Contributions and ideas are welcome. Fork the project, enhance it, and open a pull request!

---

## ๐Ÿ How to Run

1. ๐Ÿ“ฅ Clone the repository:
```bash
git clone https://github.com/your-username/clsStack_With_Dynamic_Array_Library-CPP.git
cd clsMyStackArr-CPP
```
2. ๐Ÿ›  Include in your project:
```bash

#include"clsMyQueueArr.h"
#include"clsDynamicArray.h"
#invlude"clsMyStackArr.h"
```
3. ๐Ÿงช Compile and run using a C++ compiler:

```bash
g++ main.cpp -o app
./app
```