LinkedStack is a simple implementation of a Stack DS using a Doubly Linked List.
Steps for running the examples in main.cpp
- Clone the repo:
git clone https://github.com/javierramoss/LinkedStack.git
- Compile using the command from within the project folder:
g++ main.cpp linkedstack.hpp contact.hpp
LinkedStack can be implemented to a proyect of your own by including linkedstack.hpp
in your project directory and compiling accordingly. It supports both primitive and abstract data types (such as structs and classes).
To use the LinkedStack DS simply specify the type
and a undefined variable of the same type
to pass to the constructor:
LinkedStack<type> myLinkedStack(type());
The main.cpp
example file shows the LinkedStack basic functionality using pointers and how to use the copy constructor and copy assignment operators properly. It first creates a LinkedStack for integers, and a LinkedStack for the Contact class defined in contact.hpp
which represents a person's contact information.
empty()
returns 1
when the stack is empty, otherwise 0
.
size()
returns the current size of the stack.
top()
returns the element at the top of the stack.
back()
returns the element at the bottom of the stack.
pop()
returns the element at the top of the stack and pops it.
push()
adds a new element x
to the front of the stack.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b NewBranch
) - Commit your Changes (
git commit -m 'Add x'
) - Push to the Branch (
git push origin NewBranch
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.