Rename linkedlist to singlelist
This commit is contained in:
parent
ba91c8956a
commit
cf38979faa
|
@ -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
|
||||
|
|
|
@ -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 <iostream>
|
||||
|
||||
enum OPS {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef LINKEDLIST_H
|
||||
#define LINKEDLIST_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// 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
|
|
@ -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
|
|
@ -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 <iostream>
|
||||
|
||||
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
|
Loading…
Reference in New Issue