-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
49 lines (35 loc) · 1.06 KB
/
Node.cpp
File metadata and controls
49 lines (35 loc) · 1.06 KB
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
#include <string>
#include <stdexcept>
#include "Node.hpp"
Node::Node(){
throw std::runtime_error("Not Implemented");
}
Node::Node(std::string word, int freq){
this->word = word;
this->freq = freq;
this->hashVal = -1;
this->next = nullptr;}
Node::Node(const Node& other){
this->word = other.getWord();
this->freq = other.getFreq();
this->hashVal = other.getHashVal();
this->next = other.getNext();}
Node& Node::operator=(const Node& other){
if(&other != this){
this->word = other.getWord();
this->freq = other.getFreq();
this->hashVal = other.getHashVal();
this->next = other.getNext();
}
return *this;
}
Node::~Node(){}
int Node::getFreq() const{return this->freq;}
std::string Node::getWord() const{return this->word;}
unsigned int Node::getHashVal() const{return this->hashVal;}
Node* Node::getNext() const{return this->next;}
void Node::setNext(Node* next){this->next = next;}
void Node::setHashVal(unsigned int hashVal){this->hashVal = hashVal;}
std::string Node::toString() const{
return(getWord()+" "+std::to_string(getFreq()));
}