Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
AdjustablePriorityQueue< T, Comp > Class Template Reference

#include <adjustable_priority_queue.h>

Public Member Functions

 AdjustablePriorityQueue ()=default
 
 AdjustablePriorityQueue (const Comp &c)
 
 AdjustablePriorityQueue (const AdjustablePriorityQueue &)=delete
 
AdjustablePriorityQueueoperator= (const AdjustablePriorityQueue &)=delete
 
 AdjustablePriorityQueue (AdjustablePriorityQueue &&)=default
 
AdjustablePriorityQueueoperator= (AdjustablePriorityQueue &&)=default
 
void Add (T *val)
 
void Remove (T *val)
 
bool Contains (const T *val) const
 
void NoteChangedPriority (T *val)
 
T * Top ()
 
const T * Top () const
 
void AllTop (std::vector< T * > *topvec)
 
void Pop ()
 If there are ties for the top, this returns all of them.
 
int Size () const
 
int Capacity () const
 Returns the number of elements for which storage has been allocated.
 
void SetCapacity (size_t c)
 Allocates storage for a given number of elements.
 
bool IsEmpty () const
 
void Clear ()
 
void CheckValid ()
 
const std::vector< T * > * Raw () const
 

Detailed Description

template<typename T, typename Comp = std::less<T>>
class AdjustablePriorityQueue< T, Comp >

Definition at line 36 of file adjustable_priority_queue.h.

Constructor & Destructor Documentation

◆ AdjustablePriorityQueue() [1/4]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue< T, Comp >::AdjustablePriorityQueue ( )
default

The objects references 'c' and 'm' are not required to be alive for the lifetime of this object.

◆ AdjustablePriorityQueue() [2/4]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue< T, Comp >::AdjustablePriorityQueue ( const Comp & c)
inlineexplicit

Definition at line 41 of file adjustable_priority_queue.h.

◆ AdjustablePriorityQueue() [3/4]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue< T, Comp >::AdjustablePriorityQueue ( const AdjustablePriorityQueue< T, Comp > & )
delete

◆ AdjustablePriorityQueue() [4/4]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue< T, Comp >::AdjustablePriorityQueue ( AdjustablePriorityQueue< T, Comp > && )
default

Member Function Documentation

◆ Add()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::Add ( T * val)
inline

Extend the size of the vector by one. We could just use vector<T>::resize(), but maybe T is not default-constructible.

Definition at line 47 of file adjustable_priority_queue.h.

◆ AllTop()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::AllTop ( std::vector< T * > * topvec)
inline

Implements breadth-first search down tree, stopping whenever there's an element < top

Definition at line 89 of file adjustable_priority_queue.h.

◆ Capacity()

template<typename T , typename Comp = std::less<T>>
int AdjustablePriorityQueue< T, Comp >::Capacity ( ) const
inline

Returns the number of elements for which storage has been allocated.

Definition at line 120 of file adjustable_priority_queue.h.

◆ CheckValid()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::CheckValid ( )
inline

CHECKs that the heap is actually a heap (each "parent" of >= priority than its child).

Definition at line 131 of file adjustable_priority_queue.h.

◆ Clear()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::Clear ( )
inline

Definition at line 127 of file adjustable_priority_queue.h.

◆ Contains()

template<typename T , typename Comp = std::less<T>>
bool AdjustablePriorityQueue< T, Comp >::Contains ( const T * val) const
inline

Definition at line 67 of file adjustable_priority_queue.h.

◆ IsEmpty()

template<typename T , typename Comp = std::less<T>>
bool AdjustablePriorityQueue< T, Comp >::IsEmpty ( ) const
inline

Definition at line 125 of file adjustable_priority_queue.h.

◆ NoteChangedPriority()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::NoteChangedPriority ( T * val)
inline

Definition at line 72 of file adjustable_priority_queue.h.

◆ operator=() [1/2]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue & AdjustablePriorityQueue< T, Comp >::operator= ( AdjustablePriorityQueue< T, Comp > && )
default

◆ operator=() [2/2]

template<typename T , typename Comp = std::less<T>>
AdjustablePriorityQueue & AdjustablePriorityQueue< T, Comp >::operator= ( const AdjustablePriorityQueue< T, Comp > & )
delete

◆ Pop()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::Pop ( )
inline

If there are ties for the top, this returns all of them.

Definition at line 115 of file adjustable_priority_queue.h.

◆ Raw()

template<typename T , typename Comp = std::less<T>>
const std::vector< T * > * AdjustablePriorityQueue< T, Comp >::Raw ( ) const
inline

This is for debugging, e.g. the caller can use it to examine the heap for rationality w.r.t. other parts of the program.

Definition at line 149 of file adjustable_priority_queue.h.

◆ Remove()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::Remove ( T * val)
inline

Definition at line 54 of file adjustable_priority_queue.h.

◆ SetCapacity()

template<typename T , typename Comp = std::less<T>>
void AdjustablePriorityQueue< T, Comp >::SetCapacity ( size_t c)
inline

Allocates storage for a given number of elements.

Definition at line 123 of file adjustable_priority_queue.h.

◆ Size()

template<typename T , typename Comp = std::less<T>>
int AdjustablePriorityQueue< T, Comp >::Size ( ) const
inline

Definition at line 117 of file adjustable_priority_queue.h.

◆ Top() [1/2]

template<typename T , typename Comp = std::less<T>>
T * AdjustablePriorityQueue< T, Comp >::Top ( )
inline

If val ever changes its priority, you need to call this function to notify the pq so it can move it in the heap accordingly.

Definition at line 85 of file adjustable_priority_queue.h.

◆ Top() [2/2]

template<typename T , typename Comp = std::less<T>>
const T * AdjustablePriorityQueue< T, Comp >::Top ( ) const
inline

Definition at line 87 of file adjustable_priority_queue.h.


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