Work on adding example for basic datastructs

This commit is contained in:
Shaun Reed 2020-03-23 10:30:27 +00:00
parent cb00bea475
commit 5bbca3d0e9
4 changed files with 115 additions and 0 deletions

View File

@ -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/ )

View File

@ -0,0 +1,42 @@
#include <lib-datastruct.h>
#include <iostream>
enum OPS {
EXIT, LISTS, STACKS, QUEUES
};
int main ()
{
// std::cout << "Running driver program version " << DS_VERSION;
bool exit = false;
LinkedList<int> 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;
}

View File

@ -0,0 +1,38 @@
#ifndef LDS_H
#define LDS_H
#include <iostream>
enum CONST {
MAX=10
};
template <typename T>
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 <typename T>
class LinkedList {
public:
LinkedList() {};
void Push(T val) {};
T Pop();
T Top();
void Display() const;
private:
// ListNode data[MAX];
};
#endif

View File

@ -0,0 +1,3 @@
#include <lib-datastruct.h>