Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * sNodeStack.hpp
- *
- * Copyright 2018 Andrew Hughes (ahughes6@buffalo.edu)
- *
- * This work is licensed under the Creative Commons
- * Attribution-NonCommercial-ShareAlike 4.0 International License.
- * To view a copy of this license, visit
- * http://creativecommons.org/licenses/by-nc-sa/4.0/.
- *
- * Submission by
- * UBIT:
- * Person#:
- */
- #ifndef _SNODESTACK_HPP_
- #define _SNODESTACK_HPP_
- #include "sNode.hpp"
- template<typename T>
- class sNodeStack {
- public:
- // Do not change visibility or type of head.
- cse250::sNode<T>* head;
- cse250::sNode<T>* tail;
- // Define necessary stack functionality.
- sNodeStack(){
- head = nullptr;
- }
- ~sNodeStack(){
- }
- void push(const T& value) {
- //Lecture 9/28
- cse250::sNode<T>* temp = new cse250::sNode<T>;
- temp->value = value;
- temp->next = head;
- head = temp;
- }
- T& top(){
- return head->value;
- }
- void pop(){
- cse250::sNode<T>* temp = head;
- head = head->next;
- delete temp;
- }
- bool empty() const{
- if(head == nullptr){
- return true;
- }
- return false;
- }
- };//sNodeStack
- #endif //_SNODESTACK_HPP_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement