ERASE method returns bool (like dictionnary)

This commit is contained in:
Patrick Pelissier committed 2018-10-27 22:43:06 +02:00
1 parent f7f7d7bc38
commit 12bf9c0f59
2 files changed
+8 -3

No files matched your search

+3 -2
View File
@@ -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 \
+5 -1
View File
@@ -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);
}