improved FineList

This commit is contained in:
2020-12-30 21:13:44 +01:00
parent a5eb49bc2e
commit 83e1a4c031
2 changed files with 19 additions and 8 deletions

View File

@@ -1,22 +1,29 @@
#include <mutex>
class Node {
public:
int data;
bool is_dummy;
Node* next;
std::mutex mut;
protected:
int data;
bool is_dummy;
std::mutex mut;
public:
Node* next;
Node(int element);
static Node* Dummy();
// Dummy();
void lock();
void unlock();
bool is_smaller_than(int n);
bool is_smaller_than(Node* n);
bool is_equal(int n);
};
Node::Node(int element){
this->data = element;
this->is_dummy = false;
data = element;
is_dummy = false;
}
Node* Node::Dummy(){
@@ -25,6 +32,10 @@ Node* Node::Dummy(){
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->is_dummy;