feat(queue): implemented clear function
This commit is contained in:
parent
f0c224d879
commit
0dfa753a56
3 changed files with 12 additions and 0 deletions
|
|
@ -43,6 +43,8 @@ FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value);
|
|||
void *fledasty_queue_peek(const FledastyQueue *current_queue);
|
||||
void *fledasty_queue_pop(FledastyQueue *current_queue);
|
||||
|
||||
FledastyError fledasty_queue_clear(FledastyQueue *current_queue);
|
||||
|
||||
static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue->size == 0; }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -125,3 +125,12 @@ void *fledasty_queue_pop(FledastyQueue *current_queue) {
|
|||
|
||||
return value_address;
|
||||
}
|
||||
|
||||
FledastyError fledasty_queue_clear(FledastyQueue *current_queue) {
|
||||
if (current_queue == NULL) {
|
||||
return FLEDASTY_ERROR_INVALID_POINTER;
|
||||
}
|
||||
|
||||
current_queue->size = 0;
|
||||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ int main() {
|
|||
printf("Queue popped: %d\n", *popped_data);
|
||||
}
|
||||
|
||||
fledasty_queue_clear(&test_queue);
|
||||
if (fledasty_queue_is_empty(&test_queue)) {
|
||||
printf("Queue is empty\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue