From 5e0fb5c94208896f1e0916fc3b4b346cdb19f4ac Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 22 Mar 2024 04:39:45 +0200 Subject: [PATCH] Add return values to remove and remove_if functions --- include_std/list | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include_std/list b/include_std/list index 25b6a80..6564f80 100644 --- a/include_std/list +++ b/include_std/list @@ -208,10 +208,11 @@ namespace std } } - void remove(const T &value) + size_t remove(const T &value) { SmartLock(this->lock); node *p = head; + size_t count = 0; while (p != nullptr) { if (p->value == value) @@ -226,17 +227,19 @@ namespace std tail = p->prev; delete p; --lSize; - return; + ++count; } p = p->next; } + return count; } template - void remove_if(UnaryPredicate p) + size_t remove_if(UnaryPredicate p) { SmartLock(this->lock); node *n = head; + size_t count = 0; while (n != nullptr) { if (p(n->value)) @@ -251,10 +254,11 @@ namespace std tail = n->prev; delete n; --lSize; - return; + ++count; } n = n->next; } + return count; } void reverse()