Grok 20.3.2
grk::MinHeapPtr< T, IT, L > Class Template Reference

Thread-safe min-heap for pointers with customizable locking. More...

#include <MinHeap.h>

Inheritance diagram for grk::MinHeapPtr< T, IT, L >:
grk::MinHeapBase< IT >

Public Member Functions

void push (T *val)
 Pushes a pointer onto the heap.
std::vector< T * > pop (T *val)
 Optionally pushes a pointer and pops all consecutive elements starting from 'start'.
size_t size () const
 Returns the current size of the heap.

Private Attributes

std::priority_queue< T *, std::vector< T * >, MinHeapPtrComparator< T > > queue
 Underlying min-heap.

Additional Inherited Members

Protected Member Functions inherited from grk::MinHeapBase< IT >
 MinHeapBase ()
Protected Attributes inherited from grk::MinHeapBase< IT >
std::mutex queue_mutex
 Mutex for thread-safe access.
IT start
 Tracks the next expected index for sequential popping.

Detailed Description

template<typename T, typename IT, typename L>
requires HasGetIndex<T> && std::integral<IT>
class grk::MinHeapPtr< T, IT, L >

Thread-safe min-heap for pointers with customizable locking.

Template Parameters
TType pointed to, must satisfy HasGetIndex.
ITIntegral type for indexing (e.g., int, size_t).
LLocker type (e.g., MinHeapLocker or MinHeapFakeLocker).

Member Function Documentation

◆ pop()

template<typename T, typename IT, typename L>
std::vector< T * > grk::MinHeapPtr< T, IT, L >::pop ( T * val)
inline

Optionally pushes a pointer and pops all consecutive elements starting from 'start'.

Parameters
valPointer to push (nullptr means no push).
Returns
Vector of popped pointers in index order (ownership transferred to caller).

References queue, grk::MinHeapBase< IT >::queue_mutex, and grk::MinHeapBase< IT >::start.

◆ push()

template<typename T, typename IT, typename L>
void grk::MinHeapPtr< T, IT, L >::push ( T * val)
inline

Pushes a pointer onto the heap.

Parameters
valPointer to the value to add (ownership not taken).

References queue, and grk::MinHeapBase< IT >::queue_mutex.

◆ size()

template<typename T, typename IT, typename L>
size_t grk::MinHeapPtr< T, IT, L >::size ( ) const
inline

Returns the current size of the heap.

Returns
Number of pointers in the heap.

References queue, and grk::MinHeapBase< IT >::queue_mutex.

Member Data Documentation

◆ queue

template<typename T, typename IT, typename L>
std::priority_queue<T*, std::vector<T*>, MinHeapPtrComparator<T> > grk::MinHeapPtr< T, IT, L >::queue
private

Underlying min-heap.

Referenced by pop(), push(), and size().


The documentation for this class was generated from the following file: