-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<iostream> | ||
|
||
#include<string> | ||
#include<"list.h"> | ||
|
||
List::List(){ | ||
head = nullptr; | ||
} | ||
|
||
List::~List(){ | ||
} | ||
|
||
void List::insert(std::string data){ | ||
Node *t = new Node(item,nullptr); | ||
if (head == nullptr) | ||
head=t; | ||
else{ | ||
t->setNext(head); | ||
head=t; | ||
} | ||
} | ||
|
||
std::string List:getDebugString(){ | ||
std::string s = ""; | ||
Node *t = head; | ||
while (t != nullptr){ | ||
s = s+t->getData() + "->"; | ||
t=t->getNext(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
class List{ | ||
private: | ||
|
||
public: | ||
List(); | ||
~List(); | ||
void List::insert(std::string data); | ||
std::string List:getDebugString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
#include <iostream> | ||
|
||
#include "node.cpp" | ||
#include "list.cpp" | ||
|
||
int main() | ||
{ | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <iostream> | ||
#include "node.h" | ||
Node::Node() : next(nullptr) | ||
{ | ||
} | ||
|
||
Node::Node(std::string data){ | ||
this->data = data; | ||
this->next = nullptr; | ||
} | ||
|
||
Node::Node(std::string data, Node *next){ | ||
this->data = data; | ||
this->next = next; | ||
} | ||
|
||
void Node::setData(std::string data){ | ||
this->data = data; | ||
} | ||
|
||
void Node::setNext(Node *next){ | ||
this->next = next; | ||
} | ||
|
||
std::string Node::getData(){ | ||
return data; | ||
} | ||
|
||
Node* Node::getNext(){ | ||
return next; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
class Node{ | ||
private: | ||
std::string data; | ||
Node *next; | ||
public: | ||
Node(); | ||
Node(std::string data); | ||
Node(std::string data, Node* next); | ||
void setData(std::string data); | ||
void setNext(Node *next); | ||
std::string getData(); | ||
Node* getNext(); | ||
}; |