You can tell whether an item already exists in the array when calling

array_appendu() now.
This commit is contained in:
David Given 2016-09-28 23:39:00 +02:00
parent 4572f1b774
commit ba1a3656a1
2 changed files with 7 additions and 4 deletions

View file

@ -31,10 +31,13 @@ bool array_contains(void* arrayp, void* value)
return false;
}
void array_appendu(void* arrayp, void* value)
bool array_appendu(void* arrayp, void* value)
{
if (!array_contains(arrayp, value))
if (array_contains(arrayp, value))
return true;
array_append(arrayp, value);
return false;
}
void array_remove(void* arrayp, void* value)

View file

@ -18,7 +18,7 @@ struct array
}
extern void array_append(void* array, void* value);
extern void array_appendu(void* array, void* value);
extern bool array_appendu(void* array, void* value);
extern void array_remove(void* array, void* value);
extern bool array_contains(void* array, void* value);