From 5bbca3d0e9a07d24a02488850cd5cd2396825626 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Mon, 23 Mar 2020 10:30:27 +0000 Subject: [PATCH] Work on adding example for basic datastructs --- plates/cpp-datastruct/CMakeLists.txt | 32 ++++++++++++++ plates/cpp-datastruct/apps/driver.cpp | 42 +++++++++++++++++++ .../cpp-datastruct/include/lib-datastruct.h | 38 +++++++++++++++++ plates/cpp-datastruct/src/lib-datastruct.cpp | 3 ++ 4 files changed, 115 insertions(+) create mode 100644 plates/cpp-datastruct/CMakeLists.txt create mode 100644 plates/cpp-datastruct/apps/driver.cpp create mode 100644 plates/cpp-datastruct/include/lib-datastruct.h create mode 100644 plates/cpp-datastruct/src/lib-datastruct.cpp diff --git a/plates/cpp-datastruct/CMakeLists.txt b/plates/cpp-datastruct/CMakeLists.txt new file mode 100644 index 0000000..0619e30 --- /dev/null +++ b/plates/cpp-datastruct/CMakeLists.txt @@ -0,0 +1,32 @@ +############################################################################### +## Author: Shaun reserved ## +## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## + +# Define the version of CMake +cmake_minimum_required(VERSION 3.10) +# Name and version of our project +project(DataStruct VERSION 0.1) +# Specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Create path variables relative to root directory (CMAKE_SOURCE_DIR) +set(APPS_DIR ./apps) +set(SRC_DIR ./src) +set(INCLUDE_DIR ./include) +set(DRIVER_SRC ${APPS_DIR}/driver.cpp) +set(LIB_DS_SRC ${SRC_DIR}/lib-datastruct.cpp) + +add_library(lib-ds ${LIB_DS_SRC}) + +add_executable(Driver ${DRIVER_SRC}) + +target_link_libraries(Driver PUBLIC lib-ds) + +target_include_directories(lib-ds PUBLIC ${INCLUDE_DIR}) + +# configure_file(${INCLUDE_DIR}/lib-datastruct.h.in ${CMAKE_BINARY_DIR}/generated/lib-datastruct.h) +# include_directories( ${CMAKE_BINARY_DIR}/generated/ ) diff --git a/plates/cpp-datastruct/apps/driver.cpp b/plates/cpp-datastruct/apps/driver.cpp new file mode 100644 index 0000000..a4607d5 --- /dev/null +++ b/plates/cpp-datastruct/apps/driver.cpp @@ -0,0 +1,42 @@ +#include +#include + +enum OPS { + EXIT, LISTS, STACKS, QUEUES +}; + +int main () +{ + // std::cout << "Running driver program version " << DS_VERSION; + + bool exit = false; + LinkedList t; + int choice; + while (!exit) { + std::cout << "Enter a choice below...\n\t0. Exit" + << "\n\t1. LISTS\n\t2. STACKS\n\t3. QUEUES\n"; + std::cin >> choice; + std::cin.clear(); + + switch (choice) { + case EXIT: // 0 + exit = true; + break; + + case LISTS: // 1 + break; + + case STACKS: // 2 + break; + + case QUEUES: // 3 + break; + + default: + std::cout << "Invalid option selected\n"; + break; + } + } + + return 0; +} diff --git a/plates/cpp-datastruct/include/lib-datastruct.h b/plates/cpp-datastruct/include/lib-datastruct.h new file mode 100644 index 0000000..ff08393 --- /dev/null +++ b/plates/cpp-datastruct/include/lib-datastruct.h @@ -0,0 +1,38 @@ +#ifndef LDS_H +#define LDS_H + +#include + +enum CONST { + MAX=10 +}; + +template +class ListNode { + public: + ListNode() : next(NULL) {}; + ListNode(T val) : data(val), next(NULL) {}; + // Sneak more of Push() through node concstr? + // ListNode(T val, LinkedList& l) data(val), next(l.Top()); + private: + T data; + ListNode* next; + +}; + +template +class LinkedList { + + public: + LinkedList() {}; + void Push(T val) {}; + T Pop(); + T Top(); + void Display() const; + + private: + // ListNode data[MAX]; + +}; + +#endif diff --git a/plates/cpp-datastruct/src/lib-datastruct.cpp b/plates/cpp-datastruct/src/lib-datastruct.cpp new file mode 100644 index 0000000..85f3ab6 --- /dev/null +++ b/plates/cpp-datastruct/src/lib-datastruct.cpp @@ -0,0 +1,3 @@ +#include + +