diff --git a/m-prioqueue.h b/m-prioqueue.h index 92d41b1b..e9f40ee2 100644 --- a/m-prioqueue.h +++ b/m-prioqueue.h @@ -275,7 +275,7 @@ M_IF_METHOD(EQUAL, oplist) \ ( \ /* EQUAL & CMP may be uncorrelated */ \ - static inline void \ + static inline bool \ M_C(name, _erase)(prioqueue_t p, type x) \ { \ /* First pass: search for an item EQUAL to x */ \ @@ -287,7 +287,7 @@ } \ /* If x is not found, then stop */ \ if (i >= size) \ - return; \ + return false; \ /* Swap the found item and the last element */ \ size--; \ M_C(name, _array_swap_at) (p->array, i, size); \ @@ -305,6 +305,7 @@ M_C(name, _array_swap_at) (p->array, i, child); \ i = child; \ } \ + return true; \ } \ \ static inline void \ diff --git a/tests/test-mprioqueue.c b/tests/test-mprioqueue.c index 0d4690ba..5288ee7d 100644 --- a/tests/test-mprioqueue.c +++ b/tests/test-mprioqueue.c @@ -68,7 +68,11 @@ static void test1(void) int_pqueue_push(p, 5); int_pqueue_pop(&x, p); assert (x == 5); - + int_pqueue_push(p, 17); + bool b = int_pqueue_erase(p, 17); + assert(b); + b = int_pqueue_erase(p, 1742); + assert(!b); int_pqueue_clear(p); }