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

Function priority_queue_top

priority_queue/priority_queue.c:461–476  ·  view source on GitHub ↗

* @brief Borrowed pointer to the highest-priority element (heap root). * * This is the element that @ref priority_queue_pop will remove next. * The returned pointer becomes stale the moment the underlying buffer * is reallocated (any push / emplace / pop / reserve / clear / swap / * assign can invalidate it). * * @param pq Queue pointer. * @return Pointer to the root element, or NULL if @p

Source from the content-addressed store, hash-verified

459 * assign can invalidate it).
460 *
461 * @param pq Queue pointer.
462 * @return Pointer to the root element, or NULL if @p pq is NULL or empty.
463 */
464void* priority_queue_top(const PriorityQueue* pq) {
465 PQUEUE_LOG("[priority_queue_top]: enter pq=%p", (const void*)pq);
466 if (!pq || !pq->vec) {
467 PQUEUE_LOG("[priority_queue_top]: NULL receiver -> NULL");
468 return NULL;
469 }
470 if (vector_is_empty(pq->vec)) {
471 PQUEUE_LOG("[priority_queue_top]: empty queue -> NULL");
472 return NULL;
473 }
474
475 void* out = vector_front(pq->vec);
476 PQUEUE_LOG("[priority_queue_top]: exit -> %p", out);
477
478 return out;
479}

Callers 1

priority_queue_frontFunction · 0.85

Calls 2

vector_is_emptyFunction · 0.85
vector_frontFunction · 0.85

Tested by

no test coverage detected