Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdsherbert/simple-stack-implementation
Simple C++ Stack class template using a custom Node structure to behave like a linked list structure.
https://github.com/jdsherbert/simple-stack-implementation
boilerplate boilerplate-template cpp cpp11 cpp14 cpp17 cpp20 generic list reference stack stackoperation stackoperations
Last synced: about 18 hours ago
JSON representation
Simple C++ Stack class template using a custom Node structure to behave like a linked list structure.
- Host: GitHub
- URL: https://github.com/jdsherbert/simple-stack-implementation
- Owner: JDSherbert
- License: mit
- Created: 2023-11-29T14:31:28.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2023-12-04T17:05:01.000Z (10 months ago)
- Last Synced: 2024-09-24T20:58:21.155Z (about 23 hours ago)
- Topics: boilerplate, boilerplate-template, cpp, cpp11, cpp14, cpp17, cpp20, generic, list, reference, stack, stackoperation, stackoperations
- Language: C++
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![image](https://github.com/JDSherbert/Threadsafe-Singleton-Class/assets/43964243/8a288a74-0a1e-4fcb-a5d8-608bb7c9d46b)
# Simple Stack Implementation
-----------------------------------------------------------------------
-----------------------------------------------------------------------
## Overview
You can use this Stack class with different types, such as int, double, std::string, or custom types, by specifying the desired type `` when creating an instance of the stack.
```
// Example usage of this stack
Stack intStack;
intStack.push(69);
intStack.push(420);std::cout << "Size of the stack: " << intStack.size() << std::endl;
std::cout << "Top element: " << intStack.peek() << std::endl;intStack.pop();
std::cout << "After pop, size of the stack: " << intStack.size() << std::endl;
```This version of a Stack class uses a linked list with a custom Node structure instead of relying on `std::list` or `std::vector`. The push, pop, peek, isEmpty, and size functions operate on this linked list. The Node structure represents each element in the stack, and the next pointer links the elements together in the stack.
-----------------------------------------------------------------------