mirror of
https://github.com/13hannes11/UU_la_parallel_programming_practical_assignments.git
synced 2024-09-04 00:50:58 +02:00
implemented contains function
This commit is contained in:
@@ -93,5 +93,23 @@ bool Set::rmv(int element) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool Set::ctn(int element) {
|
bool Set::ctn(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) {
|
||||||
|
c->unlock();
|
||||||
|
p->unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c->unlock();
|
||||||
|
p->unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user