31 #ifndef GUM_PRIORITY_QUEUE_H 32 #define GUM_PRIORITY_QUEUE_H 35 #include <initializer_list> 38 #include <type_traits> 47 #define GUM_PRIORITY_QUEUE_DEFAULT_CAPACITY 10 50 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
52 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
80 template <
typename Val,
90 template <
typename V,
typename P,
typename C,
typename A,
bool g >
107 typename Alloc::template rebind< std::pair< Val, Size > >::other;
111 typename Alloc::template rebind< std::pair< Priority, const Val* > >::other;
139 std::initializer_list< std::pair< Val, Priority > > list);
153 template <
typename OtherAlloc >
204 template <
typename OtherAlloc >
243 bool empty() const noexcept;
250 bool contains(const Val& val) const;
254 const Val&
top() const;
310 template < typename... Args >
353 void erase(const Val& val);
383 void setPriority(const Val& elt, const Priority& new_priority);
391 void setPriority(const Val& elt, Priority&& new_priority);
402 const Priority& priority(const Val& elt) const;
473 #ifndef DOXYGEN_SHOULD_SKIP_THIS 499 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
505 template <
typename V,
typename P,
typename C,
typename A,
bool g >
522 typename Alloc::template rebind< std::pair< Val, Size > >::other;
526 typename Alloc::template rebind< std::pair< Priority, Val > >::other;
554 std::initializer_list< std::pair< Val, Priority > > list);
568 template <
typename OtherAlloc >
619 template <
typename OtherAlloc >
658 bool empty()
const noexcept;
669 const Val&
top()
const;
725 template <
typename... Args >
798 void setPriority(Val elt,
const Priority& new_priority);
806 void setPriority(Val elt, Priority&& new_priority);
817 const Priority&
priority(Val elt)
const;
956 template <
typename Val,
957 typename Priority = int,
958 typename Cmp = std::less< Priority >,
959 typename Alloc = std::allocator< Val > >
965 std::is_scalar< Val >::value > {
983 std::is_scalar< Val >::value >;
1011 std::initializer_list< std::pair< Val, Priority > > list);
1023 template <
typename OtherAlloc >
1068 template <
typename OtherAlloc >
1085 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1086 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1090 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1091 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS std::ptrdiff_t difference_type
Val pop()
Removes the top element from the priority queue and return it.
bool empty() const noexcept
Indicates whether the priority queue is empty.
Size setPriorityByPos(Size index, const Priority &new_priority)
Modifies the priority of the element at position "index" of the queue.
const Val & operator[](Size index_elt) const
Returns the element at index "index_elt" from the priority queue.
The internal class for representing priority queues.
const HashTable< Val, Size > & allValues() const noexcept
Returns a hashtable the keys of which are the values stored in the queue.
const Priority & priority(const Val &elt) const
Returns the priority of an instance of the value passed in argument.
void eraseByPos(Size index)
Removes the element at position "index" from the priority queue.
static constexpr Size default_size
The default number of slots in hashtables.
const Val & top() const
returns the element at the top of the priority queue
Size emplace(Args &&... args)
Emplace a new element into the priority queue.
Size __nb_elements
The number of elements in the heap.
const Priority & priorityByPos(Size index) const
Returns the priority of the value passed in argument.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
PriorityQueueImplementation< Val, Priority, Cmp, Alloc, Gen > & operator=(const PriorityQueueImplementation< Val, Priority, Cmp, Alloc, Gen > &from)
Copy operator.
The class for generic Hash Tables.
void erase(const Val &val)
Removes a given element from the priority queue (but does not return it).
void setPriority(const Val &elt, const Priority &new_priority)
Modifies the priority of each instance of a given element.
HashTable< Val, Size, IndexAllocator > __indices
A hashtable for quickly finding the elements by their value.
typename std::allocator< NodeId > ::template rebind< std::pair< double, const NodeId * > >::other HeapAllocator
NodeId value_type
Types for STL compliance.
A priorityQueue is a heap in which each element has a mutable priorityA priority queue is quite simil...
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
std::ptrdiff_t difference_type
void eraseTop()
Removes the top of the priority queue (but does not return it).
std::string toString() const
Displays the content of the queue.
std::vector< std::pair< Priority, const Val *>, HeapAllocator > __heap
An array storing all the elements of the heap as well as their score.
Size insert(const Val &val, const Priority &priority)
Inserts a new (a copy) element in the priority queue.
std::allocator< NodeId > allocator_type
std::allocator< gum::Edge > allocator_type
Size capacity() const noexcept
Returns the size of the internal structure storing the priority queue.
void resize(Size new_size)
Changes the size of the internal structure storing the priority queue.
The base class for all undirected edges.
void clear()
Removes all the elements from the queue.
const NodeId * const_pointer
#define GUM_PRIORITY_QUEUE_DEFAULT_CAPACITY
const NodeId & const_reference
std::size_t Size
In aGrUM, hashed values are unsigned long int.
~PriorityQueueImplementation()
Class destructor.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
friend class PriorityQueueImplementation
All gum::PriorityQueueImplementation are friends with themselves.
typename std::allocator< NodeId > ::template rebind< std::pair< NodeId, Size > >::other IndexAllocator
const Priority & topPriority() const
Returns the priority of the top element.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool contains(const Val &val) const
Indicates whether the priority queue contains a given value.
Cmp __cmp
Comparison function.
Size size() const noexcept
Returns the number of elements in the priority queue.