operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority > Class Template Reference

Detailed Description

template<typename Element, typename IntegerPriority>
class operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >

Specific but efficient priority queue implementation.

The priority type must be an integer. The queue allows to retrieve the element with highest priority but only allows pushes with a priority greater or equal to the highest priority in the queue minus one. All operations are in O(1) and the memory is in O(num elements in the queue). Elements with the same priority are retrieved with LIFO order.

Note(user): As far as I know, this is an original idea and is the only code that use this in the Maximum Flow context. Papers usually refer to an height-indexed array of simple linked lists of active node with the same height. Even worse, sometimes they use double-linked list to allow arbitrary height update in order to detect missing height (used for the Gap heuristic). But this can actually be implemented a lot more efficiently by just maintaining the height distribution of all the node in the graph.

Definition at line 264 of file max_flow.h.

Public Member Functions

 PriorityQueueWithRestrictedPush ()
 
bool IsEmpty () const
 Is the queue empty? More...
 
void Clear ()
 Clears the queue. More...
 
void Push (Element element, IntegerPriority priority)
 Push a new element in the queue. More...
 
Element Pop ()
 Returns the element with highest priority and remove it from the queue. More...
 

Constructor & Destructor Documentation

◆ PriorityQueueWithRestrictedPush()

template<typename Element, typename IntegerPriority>
operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::PriorityQueueWithRestrictedPush ( )
inline

Definition at line 266 of file max_flow.h.

Member Function Documentation

◆ Clear()

template<typename Element , typename IntegerPriority >
void operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::Clear ( )

Clears the queue.

Definition at line 667 of file max_flow.h.

◆ IsEmpty()

template<typename Element , typename IntegerPriority >
bool operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::IsEmpty ( ) const

Is the queue empty?

Definition at line 661 of file max_flow.h.

◆ Pop()

template<typename Element , typename IntegerPriority >
Element operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::Pop ( )

Returns the element with highest priority and remove it from the queue.

IsEmpty() must be false, this condition is DCHECKed.

Definition at line 692 of file max_flow.h.

◆ Push()

template<typename Element, typename IntegerPriority>
void operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::Push ( Element  element,
IntegerPriority  priority 
)

Push a new element in the queue.

Its priority must be greater or equal to the highest priority present in the queue, minus one. This condition is DCHECKed, and violating it yields erroneous queue behavior in NDEBUG mode.

Since users may rely on it, we DCHECK the exact condition.

Note
the DCHECK() below are less restrictive than the ones above but check a necessary and sufficient condition for the priority queue to behave as expected.

Definition at line 673 of file max_flow.h.


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