30 #ifndef GUM_MULTI_PRIORITY_QUEUE_H 31 #define GUM_MULTI_PRIORITY_QUEUE_H 34 #include <initializer_list> 45 #define GUM_MULTIPLE_PRIORITY_QUEUE_DEFAULT_CAPACITY 10 47 #ifndef DOXYGEN_SHOULD_SKIP_THIS 49 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
50 class MultiPriorityQueue;
52 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
54 const MultiPriorityQueue< Val, Priority, Cmp, Alloc >&);
56 #endif // DOXYGEN_SHOULD_SKIP_THIS 123 template <
typename Val,
124 typename Priority = int,
125 typename Cmp = std::less< Priority >,
126 typename Alloc = std::allocator< Val > >
129 template <
typename V,
typename P,
typename C,
typename A >
145 using IndexAlloc =
typename Alloc::template rebind<
146 std::pair< Val, std::vector< Size > > >::other;
150 typename Alloc::template rebind< std::pair< Priority, const Val* > >::other;
179 std::initializer_list< std::pair< Val, Priority > > list);
194 template <
typename OtherAlloc >
239 template <
typename OtherAlloc >
275 bool empty() const noexcept;
282 bool contains(const Val& val) const;
289 const Val&
top() const;
340 template < typename... Args >
383 void erase(const Val& val);
413 void setPriority(const Val& elt, const Priority& new_priority);
427 const Priority& priority(const Val& elt) const;
495 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 496 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 500 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 501 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS void setPriority(const Val &elt, const Priority &new_priority)
Modifies the priority of each instance of a given element.
Size setPriorityByPos(Size index, const Priority &new_priority)
Modifies the priority of the element at position "index" of the queue.
std::vector< std::pair< Priority, const Val *>, HeapAlloc > __heap
An array storing all the elements of the heap as well as their score.
friend class MultiPriorityQueue
Making all MultiPriorityQueue friend with themselves.
const HashTable< Val, std::vector< Size > > & allValues() const
Returns a gum::HashTable the keys of which are the values stored in the queue.
const Val & operator[](Size index_elt) const
Returns the element at index "index_elt" from the priority queue.
Size __nb_elements
The number of elements in the heap.
std::string toString() const
Displays the content of the queue.
Size emplace(Args &&... args)
Emplace a new element into the priority queue.
Cmp __cmp
Comparison function.
void clear()
Removes all the elements from the queue.
#define GUM_MULTIPLE_PRIORITY_QUEUE_DEFAULT_CAPACITY
typename std::allocator< gum::LeafPair * > ::template rebind< std::pair< double, const gum::LeafPair * * > >::other HeapAlloc
The allocator for the heap.
const Val & top() const
Returns the element at the top of the priority queue.
void erase(const Val &val)
Removes a given element from the priority queue (but does not return it).
Size size() const noexcept
Returns the number of elements in the priority queue.
typename std::allocator< gum::LeafPair * > ::template rebind< std::pair< gum::LeafPair *, std::vector< Size > > >::other IndexAlloc
The allocator for the indices.
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Val pop()
Removes the top element from the priority queue and return it.
void eraseByPos(Size index)
Removes the element at position "index" from the priority queue.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool empty() const noexcept
Indicates whether the priority queue is empty.
The class for generic Hash Tables.
Size capacity() const noexcept
Return the size of the internal structure storing the priority queue.
const Priority & topPriority() const
Returns the priority of the top element.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
std::allocator< gum::LeafPair * > allocator_type
std::ptrdiff_t difference_type
Size insert(const Val &val, const Priority &priority)
Inserts a new (a copy) element in the priority queue.
void resize(Size new_size)
Changes the size of the internal structure storing the priority queue.
const Priority & priority(const Val &elt) const
Returns the priority of an instance of the value passed in argument.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiPriorityQueue< Val, Priority, Cmp, Alloc > & operator=(const MultiPriorityQueue< Val, Priority, Cmp, Alloc > &from)
Copy operator.
~MultiPriorityQueue()
Class destructor.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void eraseTop()
Removes the top of the priority queue (but does not return it).
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.
A MultiPriorityQueue is a heap in which each element has a mutable priority and duplicates are allowe...
HashTable< Val, std::vector< Size >, IndexAlloc > __indices
A hashtable for quickly finding the elements by their value.