-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntNode.cpp
56 lines (44 loc) · 1.06 KB
/
IntNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Created by hloi on 2/23/2022.
//
#include <iostream>
#include "IntNode.h"
using namespace std;
// Constructor
IntNode::IntNode(int dataInit, IntNode* nextLoc) {
this->dataVal = dataInit;
this->nextNodePtr = nextLoc;
}
// Print dataVal
void IntNode::PrintNodeData() {
cout << this->dataVal << endl;
}
// Grab location pointed by nextNodePtr
IntNode* IntNode::GetNext() {
return this->nextNodePtr;
}
void IntNode::SetNextNodePtr(IntNode *nextNodePtr) {
this->nextNodePtr = nextNodePtr;
}
int IntNode::GetDataVal() const {
return dataVal;
}
IntNode::~IntNode() {
cout << "Node destructor" << endl;
delete this->nextNodePtr;
}
bool IntNode::operator==(const IntNode* other) {
return this->dataVal == other->dataVal;
}
void IntNode::insertAfter(IntNode *node) {
IntNode* tmp = this->nextNodePtr;
SetNextNodePtr(node);
node->SetNextNodePtr(tmp);
}
void IntNode::setDataVal(int dataVal) {
IntNode::dataVal = dataVal;
}
ostream& operator<<(ostream& out, const IntNode& node) {
out << node.dataVal << endl;
return out;
}