Add CMakeLists for all datastructs
+ Reorder, refactor comments
This commit is contained in:
18
cpp/datastructs/stacklist/CMakeLists.txt
Normal file
18
cpp/datastructs/stacklist/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
###############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ##
|
||||
## About: An example of a stack implementation using linked lists ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################
|
||||
## CMakeLists.txt
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
# Define the project name
|
||||
project(Stack)
|
||||
# Define source files
|
||||
set(SRC driver.cpp stacklist.cpp)
|
||||
# Build an executable
|
||||
add_executable(StackDriver ${SRC})
|
||||
@@ -65,4 +65,3 @@ int main()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ StackList::~StackList()
|
||||
/** push
|
||||
* @brief Push a value to the head of our linked list
|
||||
*
|
||||
* @param x The value to be inserted
|
||||
* @param val The value to be inserted
|
||||
*/
|
||||
bool StackList::push(int val)
|
||||
{
|
||||
@@ -146,7 +146,6 @@ bool StackList::isEmpty() const
|
||||
return head == NULL;
|
||||
}
|
||||
|
||||
|
||||
/** print
|
||||
* @brief Output the data held by the StackList object
|
||||
* Calls to the private print()
|
||||
@@ -180,6 +179,12 @@ bool StackList::push(int val, Node *&head)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** pop
|
||||
* @brief Private member to handle removing the head node from the stack
|
||||
*
|
||||
* @param head The head node of the stack
|
||||
* @return The last known value held at the head node before removal
|
||||
*/
|
||||
int StackList::pop(Node *&head)
|
||||
{
|
||||
// We already know the stack is not empty from public pop()
|
||||
|
||||
Reference in New Issue
Block a user