MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / priority_queue_clear

Function priority_queue_clear

priority_queue/priority_queue.c:678–690  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

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 */
681void 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}

Callers

nothing calls this directly

Calls 3

vector_sizeFunction · 0.85
vector_clearFunction · 0.85
vector_capacityFunction · 0.85

Tested by

no test coverage detected