* @brief Remove every element. Underlying capacity is retained. * * After this call `priority_queue_empty(pq) == true` and * `priority_queue_size(pq) == 0`, but subsequent pushes can reuse the * existing buffer without re-allocating up to its current capacity. * * @param pq Queue to clear. NULL is a no-op. */
| 676 | * `priority_queue_size(pq) == 0`, but subsequent pushes can reuse the |
| 677 | * existing buffer without re-allocating up to its current capacity. |
| 678 | * |
| 679 | * @param pq Queue to clear. NULL is a no-op. |
| 680 | */ |
| 681 | void priority_queue_clear(PriorityQueue* pq) { |
| 682 | PQUEUE_LOG("[priority_queue_clear]: enter pq=%p", (void*)pq); |
| 683 | if (!pq || !pq->vec) { |
| 684 | PQUEUE_LOG("[priority_queue_clear]: NULL receiver, no-op"); |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | size_t before = vector_size(pq->vec); |
| 689 | vector_clear(pq->vec); |
| 690 | |
| 691 | PQUEUE_LOG("[priority_queue_clear]: exit (cleared %zu elements; capacity = %zu)", before, vector_capacity(pq->vec)); |
| 692 | (void)before; |
| 693 | } |
nothing calls this directly
no test coverage detected