setup project for assignment 3

This commit is contained in:
2021-01-08 16:01:54 +01:00
parent 51b54f68fb
commit 2f9f32e50e
13 changed files with 268 additions and 0 deletions

43
Assignment_3/lib/Node.cpp Normal file
View File

@@ -0,0 +1,43 @@
#include <mutex>
#include <lib/Node.h>
Node::Node(int element){
data = element;
dummy = false;
deleted = false;
}
Node* Node::Dummy(){
Node* n = new Node(0);
n->dummy = true;
return n;
}
bool Node::is_smaller_than(Node* n) {
return this->is_smaller_than(n->data);
}
bool Node::is_smaller_than(int n) {
// Everything is smaller than a dummy -> false
return this->data < n && !this->dummy;
}
bool Node::is_equal(int n) {
// Dummies are not equal to any number -> false
return this->data == n && !this->dummy;
}
void Node::lock() {
this->mut.lock();
}
void Node::unlock() {
this->mut.unlock();
}
bool Node::is_dummy() {
return dummy;
}
int Node::get_data(){
return data;
}