Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <integer_pq.h>
Public Member Functions | |
IntegerPriorityQueue (int n=0, Compare comp=Compare()) | |
Starts with an empty queue and reserve space for n elements. | |
void | Reserve (int n) |
int | Size () const |
Returns the number of elements currently present. | |
bool | IsEmpty () const |
void | Clear () |
bool | Contains (int index) const |
Returns true if the element with given index is currently in the queue. | |
void | Add (Element element) |
Element | Top () const |
void | Pop () |
void | Remove (int index) |
void | ChangePriority (Element element) |
void | IncreasePriority (Element element) |
Optimized version of ChangePriority() when we know the direction. | |
void | DecreasePriority (Element element) |
Element | GetElement (int index) const |
Returns the element with given index. | |
Element | QueueElement (int i) const |
Classic asjustable priority queue implementation. It behaves exactly the same as AdjustablePriorityQueue regarding identical elements, but it uses less memory and is in general slightly faster.
Definition at line 37 of file integer_pq.h.
|
inlineexplicit |
Starts with an empty queue and reserve space for n elements.
Definition at line 40 of file integer_pq.h.
|
inline |
Adds the given element to the queue and set its priority. Preconditions: Contains(element) must be false.
Definition at line 71 of file integer_pq.h.
|
inline |
Change the priority of the given element and adjust the queue.
Preconditions: Contains(element) must be true.
Definition at line 105 of file integer_pq.h.
|
inline |
Removes all elements from the queue.
Definition at line 61 of file integer_pq.h.
|
inline |
Returns true if the element with given index is currently in the queue.
Definition at line 67 of file integer_pq.h.
|
inline |
Definition at line 119 of file integer_pq.h.
|
inline |
Returns the element with given index.
Definition at line 124 of file integer_pq.h.
|
inline |
Optimized version of ChangePriority() when we know the direction.
Definition at line 116 of file integer_pq.h.
|
inline |
Definition at line 57 of file integer_pq.h.
|
inline |
Definition at line 79 of file integer_pq.h.
|
inline |
For i in [0, Size()) returns an element currently in the queue. This can be used to get a random element from the queue for instance.
Definition at line 128 of file integer_pq.h.
|
inline |
Removes the element with given index from the queue. Preconditions: Contains(index) must be true.
Definition at line 88 of file integer_pq.h.
|
inline |
Increases the space reservation to n elements indices in [0, n). All elements passed to the other functions must have an Index() smaller than this n.
The heap_ starts at 1 for faster left/right child indices computation. This also allow us to use position 0 for element not in the queue.
Definition at line 48 of file integer_pq.h.
|
inline |
Returns the number of elements currently present.
Definition at line 56 of file integer_pq.h.
|
inline |
Top() returns the top element and Pop() remove it from the queue. Preconditions: IsEmpty() must be false.
Definition at line 78 of file integer_pq.h.