mirror of
https://github.com/13hannes11/UU_la_parallel_programming_practical_assignments.git
synced 2024-09-04 00:50:58 +02:00
add implementation for remove to fine grained_list
This commit is contained in:
@@ -55,20 +55,41 @@ bool Set::add(int element) {
|
|||||||
c->unlock();
|
c->unlock();
|
||||||
p->unlock();
|
p->unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Node* n = new Node();
|
|
||||||
n->data = element;
|
|
||||||
n->next = c;
|
|
||||||
p->next = n;
|
|
||||||
|
|
||||||
c->unlock();
|
|
||||||
p->unlock();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node* n = new Node();
|
||||||
|
n->data = element;
|
||||||
|
n->next = c;
|
||||||
|
p->next = n;
|
||||||
|
|
||||||
|
c->unlock();
|
||||||
|
p->unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Set::rmv(int element) {
|
bool Set::rmv(int element) {
|
||||||
|
this->first->lock();
|
||||||
|
Node* p = this->first;
|
||||||
|
Node* c = p->next;
|
||||||
|
c->lock();
|
||||||
|
|
||||||
|
while (c->data < element) {
|
||||||
|
p->unlock();
|
||||||
|
c = c->next;
|
||||||
|
c->lock();
|
||||||
|
if (c->data == element) {
|
||||||
|
p->next = c->next;
|
||||||
|
|
||||||
|
c->unlock();
|
||||||
|
p->unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
c->unlock();
|
||||||
|
p->unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool Set::ctn(int element) {
|
bool Set::ctn(int element) {
|
||||||
|
|||||||
Reference in New Issue
Block a user