This project implements a generic Stack data structure using a templated class in C++. It supports standard stack operations along with extended functionalities for educational and debugging purposes.
-
Generic Stack: Uses C++ templates to support any data type.
-
Core Operations:
push(item)
pop()
Top()
- view the top elementBottom()
- view the bottom elementSize()
- get the number of elementsPrint()
- print the stack from top to bottom
-
Extended Functionalities:
GetItem(index)
- Get element at a specific indexReverse()
- Reverse the order of the stackUpdateItem(index, value)
- Update an item at a given indexInsertAfter(index, value)
- Insert a value after a given indexInsertAtFront(value)
- Insert a value at the top of the stackInsertAtBack(value)
- Insert a value at the bottom of the stackClear()
- Remove all elements from the stack
Stack:
50 40 30 20 10
Stack Size: 5
Stack Top: 50
Stack Bottom: 10
Stack after pop():
40 30 20 10
Item(2): 20
Stack after reverse():
10 20 30 40
Stack after updating Item(2) to 600:
10 20 600 40
Stack after Inserting 800 after Item(2):
10 20 600 800 40
Stack after Inserting 1000 at top:
1000 10 20 600 800 40
Stack after Inserting 2000 at bottom:
1000 10 20 600 800 40 2000
Stack after Clear():
(empty)
This project was built by Chiheb Abiza as a practical implementation of templated data structures in C++.
This project is licensed under the MIT License.