mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Add return values to remove and remove_if functions
This commit is contained in:
parent
6ebee99ed1
commit
5e0fb5c942
@ -208,10 +208,11 @@ namespace std
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const T &value)
|
size_t remove(const T &value)
|
||||||
{
|
{
|
||||||
SmartLock(this->lock);
|
SmartLock(this->lock);
|
||||||
node *p = head;
|
node *p = head;
|
||||||
|
size_t count = 0;
|
||||||
while (p != nullptr)
|
while (p != nullptr)
|
||||||
{
|
{
|
||||||
if (p->value == value)
|
if (p->value == value)
|
||||||
@ -226,17 +227,19 @@ namespace std
|
|||||||
tail = p->prev;
|
tail = p->prev;
|
||||||
delete p;
|
delete p;
|
||||||
--lSize;
|
--lSize;
|
||||||
return;
|
++count;
|
||||||
}
|
}
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class UnaryPredicate>
|
template <class UnaryPredicate>
|
||||||
void remove_if(UnaryPredicate p)
|
size_t remove_if(UnaryPredicate p)
|
||||||
{
|
{
|
||||||
SmartLock(this->lock);
|
SmartLock(this->lock);
|
||||||
node *n = head;
|
node *n = head;
|
||||||
|
size_t count = 0;
|
||||||
while (n != nullptr)
|
while (n != nullptr)
|
||||||
{
|
{
|
||||||
if (p(n->value))
|
if (p(n->value))
|
||||||
@ -251,10 +254,11 @@ namespace std
|
|||||||
tail = n->prev;
|
tail = n->prev;
|
||||||
delete n;
|
delete n;
|
||||||
--lSize;
|
--lSize;
|
||||||
return;
|
++count;
|
||||||
}
|
}
|
||||||
n = n->next;
|
n = n->next;
|
||||||
}
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reverse()
|
void reverse()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user