28 #ifndef GUM_PRIORITY_QUEUE_H 29 #define GUM_PRIORITY_QUEUE_H 32 #include <initializer_list> 35 #include <type_traits> 44 #define GUM_PRIORITY_QUEUE_DEFAULT_CAPACITY 10 47 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
49 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
77 template <
typename Val,
87 template <
typename V,
typename P,
typename C,
typename A,
bool g >
104 typename Alloc::template rebind< std::pair< Val, Size > >::other;
108 typename Alloc::template rebind< std::pair< Priority, const Val* > >::other;
136 std::initializer_list< std::pair< Val, Priority > > list);
150 template <
typename OtherAlloc >
201 template <
typename OtherAlloc >
240 bool empty() const noexcept;
247 bool contains(const Val& val) const;
251 const Val&
top() const;
307 template < typename... Args >
350 void erase(const Val& val);
380 void setPriority(const Val& elt, const Priority& new_priority);
388 void setPriority(const Val& elt, Priority&& new_priority);
399 const Priority& priority(const Val& elt) const;
470 #ifndef DOXYGEN_SHOULD_SKIP_THIS 496 template <
typename Val,
typename Priority,
typename Cmp,
typename Alloc >
502 template <
typename V,
typename P,
typename C,
typename A,
bool g >
519 typename Alloc::template rebind< std::pair< Val, Size > >::other;
523 typename Alloc::template rebind< std::pair< Priority, Val > >::other;
551 std::initializer_list< std::pair< Val, Priority > > list);
565 template <
typename OtherAlloc >
616 template <
typename OtherAlloc >
655 bool empty()
const noexcept;
666 const Val&
top()
const;
722 template <
typename... Args >
795 void setPriority(Val elt,
const Priority& new_priority);
803 void setPriority(Val elt, Priority&& new_priority);
814 const Priority&
priority(Val elt)
const;
953 template <
typename Val,
954 typename Priority = int,
955 typename Cmp = std::less< Priority >,
956 typename Alloc = std::allocator< Val > >
962 std::is_scalar< Val >::value > {
980 std::is_scalar< Val >::value >;
1008 std::initializer_list< std::pair< Val, Priority > > list);
1020 template <
typename OtherAlloc >
1065 template <
typename OtherAlloc >
1082 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1083 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1087 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1088 # 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.
gum is the global namespace for all aGrUM entities
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.
template implementations of priority queues
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.
Class hash tables iterators.
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.