Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority > Class Template Reference

#include <max_flow.h>

Public Member Functions

 PriorityQueueWithRestrictedPush ()
 
 PriorityQueueWithRestrictedPush (const PriorityQueueWithRestrictedPush &)=delete
 This type is neither copyable nor movable.
 
PriorityQueueWithRestrictedPushoperator= (const PriorityQueueWithRestrictedPush &)=delete
 
bool IsEmpty () const
 Is the queue empty?
 
void Clear ()
 Clears the queue.
 
void Push (Element element, IntegerPriority priority)
 
Element Pop ()
 

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 267 of file max_flow.h.

Constructor & Destructor Documentation

◆ PriorityQueueWithRestrictedPush() [1/2]

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

Definition at line 269 of file max_flow.h.

◆ PriorityQueueWithRestrictedPush() [2/2]

template<typename Element , typename IntegerPriority >
operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::PriorityQueueWithRestrictedPush ( const PriorityQueueWithRestrictedPush< Element, IntegerPriority > & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ Clear()

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

Clears the queue.

Definition at line 700 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 694 of file max_flow.h.

◆ operator=()

template<typename Element , typename IntegerPriority >
PriorityQueueWithRestrictedPush & operations_research::PriorityQueueWithRestrictedPush< Element, IntegerPriority >::operator= ( const PriorityQueueWithRestrictedPush< Element, IntegerPriority > & )
delete

◆ 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 725 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 706 of file max_flow.h.


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