From cf38979faaa65cd9a8411522a240cab01ec57902 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 15 Apr 2020 11:58:07 -0400 Subject: [PATCH] Rename linkedlist to singlelist --- plates/linkedlists/Makefile | 10 ++-- plates/linkedlists/driver.cpp | 12 ++++- plates/linkedlists/linkedlist.h | 34 ------------- .../{linkedlist.cpp => singlelist.cpp} | 12 ++++- plates/linkedlists/singlelist.h | 48 +++++++++++++++++++ 5 files changed, 75 insertions(+), 41 deletions(-) delete mode 100644 plates/linkedlists/linkedlist.h rename plates/linkedlists/{linkedlist.cpp => singlelist.cpp} (88%) create mode 100644 plates/linkedlists/singlelist.h diff --git a/plates/linkedlists/Makefile b/plates/linkedlists/Makefile index 487a578..dde1fa7 100644 --- a/plates/linkedlists/Makefile +++ b/plates/linkedlists/Makefile @@ -5,15 +5,15 @@ CXXFLAGS=-g -Wall # Driver ############################################################################### -driver: driver.cpp linkedlist.o - ${CXX} ${CXXFLAGS} driver.cpp linkedlist.o -o driver +driver: driver.cpp singlelist.o + ${CXX} ${CXXFLAGS} driver.cpp singlelist.o -o driver ############################################################################### -# LinkedList +# SingleList ############################################################################### -linkedlist.o: linkedlist.cpp linkedlist.h - ${CXX} ${CXXFLAGS} -c linkedlist.cpp -o linkedlist.o +singlelist.o: singlelist.cpp singlelist.h + ${CXX} ${CXXFLAGS} -c singlelist.cpp -o singlelist.o ############################################################################### # Clean diff --git a/plates/linkedlists/driver.cpp b/plates/linkedlists/driver.cpp index 4bfbb5d..d345cab 100644 --- a/plates/linkedlists/driver.cpp +++ b/plates/linkedlists/driver.cpp @@ -1,4 +1,14 @@ -#include "linkedlist.h" +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## About: A driver program to test a singly linked list ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +## driver.cpp +*/ + +#include "singlelist.h" #include enum OPS { diff --git a/plates/linkedlists/linkedlist.h b/plates/linkedlists/linkedlist.h deleted file mode 100644 index 6c64578..0000000 --- a/plates/linkedlists/linkedlist.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LINKEDLIST_H -#define LINKEDLIST_H - -#include - -// Singly Linked List -class SingleList{ - public: - SingleList() : head(NULL) {}; - SingleList(const SingleList& rhs); - SingleList& operator=(const SingleList& rhs); - ~SingleList(); - bool insert(int val); - bool insert(int val, int key); - void makeEmpty(); - bool isEmpty() const; - int peek() const; - void print() const; - bool find(int val) const; - - private: - struct Node { - int data; - Node *next; - Node(): data(00), next(NULL) {}; - Node(int val): data(val), next(NULL) {}; - }; - Node *head; - Node* find(int val, Node *start) const; - Node* findPrevious(int val, Node *start) const; - void print(Node *start) const; -}; - -#endif diff --git a/plates/linkedlists/linkedlist.cpp b/plates/linkedlists/singlelist.cpp similarity index 88% rename from plates/linkedlists/linkedlist.cpp rename to plates/linkedlists/singlelist.cpp index e618ac6..6200098 100644 --- a/plates/linkedlists/linkedlist.cpp +++ b/plates/linkedlists/singlelist.cpp @@ -1,4 +1,14 @@ -#include "linkedlist.h" +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## About: An example of a singly linked list ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +## singlelist.cpp +*/ + +#include "singlelist.h" /****************************************************************************** * Constructors, Destructors, Operators diff --git a/plates/linkedlists/singlelist.h b/plates/linkedlists/singlelist.h new file mode 100644 index 0000000..c26614c --- /dev/null +++ b/plates/linkedlists/singlelist.h @@ -0,0 +1,48 @@ +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## About: An example of a singly linked list ## +## ## +## Structure: Remove: Insert: Insert at: Replace: ## +## o-o-o-o-o-o o-o--x-->o-o-o o o o ## +## | /| / \ ## +## o-o~o-o-o-o o-o~o-o-o-o o-o~x~o-o-o ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +## singlelist.cpp +*/ + +#ifndef LINKEDLIST_H +#define LINKEDLIST_H + +#include + +class SingleList{ + public: + SingleList() : head(NULL) {}; + SingleList(const SingleList& rhs); + SingleList& operator=(const SingleList& rhs); + ~SingleList(); + bool insert(int val); + bool insert(int val, int key); + void makeEmpty(); + bool isEmpty() const; + int peek() const; + void print() const; + bool find(int val) const; + + private: + struct Node { + int data; + Node *next; + Node(): data(00), next(NULL) {}; + Node(int val): data(val), next(NULL) {}; + }; + Node *head; + Node* find(int val, Node *start) const; + Node* findPrevious(int val, Node *start) const; + void print(Node *start) const; +}; + +#endif