Add Node class, work on singly LinkedList class and examples
This commit is contained in:
@@ -3,6 +3,33 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Node {
|
||||
public:
|
||||
Node() : next(NULL) {};
|
||||
Node(char val) : data(val), next(NULL) {};
|
||||
char data;
|
||||
Node *next;
|
||||
};
|
||||
|
||||
// Linked list
|
||||
|
||||
class LinkedList {
|
||||
|
||||
public:
|
||||
LinkedList() : head(NULL), tail(NULL) {};
|
||||
void Append(char val);
|
||||
void Push(char val);
|
||||
void Remove(char val);
|
||||
void Replace(char remove, char replace);
|
||||
void Display() const;
|
||||
bool isEmpty() const;
|
||||
Node* Find(char val) const;
|
||||
private:
|
||||
Node *head, *tail;
|
||||
};
|
||||
|
||||
// Array based stack
|
||||
|
||||
class StackArray {
|
||||
public:
|
||||
StackArray() : top(EMPTY) {};
|
||||
@@ -14,13 +41,6 @@ class StackArray {
|
||||
|
||||
private:
|
||||
enum { EMPTY=-1, MAX=10 };
|
||||
class Node {
|
||||
public:
|
||||
Node() : next(NULL) {};
|
||||
Node(char val) : data(val), next(NULL) {};
|
||||
char data;
|
||||
Node* next;
|
||||
};
|
||||
Node stack[MAX];
|
||||
int top;
|
||||
};
|
||||
|
||||
8
plates/cpp-datastruct/include/lib-datastruct.h.in
Normal file
8
plates/cpp-datastruct/include/lib-datastruct.h.in
Normal file
@@ -0,0 +1,8 @@
|
||||
// #ifndef LDS_H
|
||||
// #define LDS_H
|
||||
|
||||
#define DS_VERSION_MINOR @DataStruct_VERSION_MINOR@
|
||||
#define DS_VERSION_MAJOR @DataStruct_VERSION_MAJOR@
|
||||
#define DS_VERSION @DataStruct_VERSION@
|
||||
|
||||
// #endif
|
||||
Reference in New Issue
Block a user