27 #ifndef GUM_MULTI_PRIORITY_QUEUE_H 28 #define GUM_MULTI_PRIORITY_QUEUE_H 31 #include <initializer_list> 42 #define GUM_MULTIPLE_PRIORITY_QUEUE_DEFAULT_CAPACITY 10 44 #ifndef DOXYGEN_SHOULD_SKIP_THIS 46 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
47 class MultiPriorityQueue;
49 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
51 const MultiPriorityQueue< Val, Priority, Cmp, Alloc >&);
53 #endif // DOXYGEN_SHOULD_SKIP_THIS 120 template <
typename Val,
121 typename Priority = int,
122 typename Cmp = std::less< Priority >,
123 typename Alloc = std::allocator< Val > >
126 template <
typename V,
typename P,
typename C,
typename A >
142 using IndexAlloc =
typename Alloc::template rebind<
143 std::pair< Val, std::vector< Size > > >::other;
147 typename Alloc::template rebind< std::pair< Priority, const Val* > >::other;
176 std::initializer_list< std::pair< Val, Priority > > list);
191 template <
typename OtherAlloc >
236 template <
typename OtherAlloc >
272 bool empty() const noexcept;
279 bool contains(const Val& val) const;
286 const Val&
top() const;
337 template < typename... Args >
380 void erase(const Val& val);
410 void setPriority(const Val& elt, const Priority& new_priority);
424 const Priority& priority(const Val& elt) const;
492 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 493 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 497 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 498 # 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.
gum is the global namespace for all aGrUM entities
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.
Template implementations of multi priority queues.
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).
Class hash tables iterators.
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.