63 template<
typename,
class>
class Impl=PairingHeap
77 using handle =
typename SpecImpl::Handle;
87 : m_size(0), m_cmp(cmp), m_impl(new
SpecImpl(cmp, initialSize))
93 : m_size(other.m_size), m_impl(new
SpecImpl(other.m_impl))
110 template<
class InputIt>
163 return m_impl->top();
173 return m_impl->push(value);
181 template<
class InputIt>
182 void push(InputIt first, InputIt last) {
183 while(first != last) {
192 void push(std::initializer_list<value_type> ilist) {
193 push(std::begin(ilist), std::end(ilist));
214 m_impl->decrease(pos, value);
224 m_impl->merge(other->
m_impl);
252 return m_impl->value(pos);
260 namespace pq_internal {
270 Compare(
const C &compare = C()) : m_compare(compare) {}
273 return m_compare(x.priority(), y.priority());
293 : m_element(element), m_priority(priority)
323 template<
typename,
class>
class Impl
332 template<
typename,
class>
class Impl
353 return SuperQueue::top().element();
358 return SuperQueue::top().priority();
368 Pair pair(element, priority);
369 Handle result = SuperQueue::push(pair);
375 Pair pair(this->
value(pos).element(), priority);
376 SuperQueue::decrease(pos, pair);
384 template<
typename,
class>
class Impl,
398 return m_handles[element] !=
nullptr;
408 return this->
value(m_handles[element]).priority();
415 void push(
const E &element,
const P &priority) {
417 m_handles[element] = SuperQueue::push(element, priority);
424 m_handles[SuperQueue::topElement()] =
nullptr;
433 void decrease(
const E &element,
const P &priority) {
434 Handle pos = m_handles[element];
435 SuperQueue::decrease(pos, priority);
446 :
SuperQueue(cmp, initialSize), m_handles(map)
472 class C=std::less<P>,
501 class C=std::less<P>,
529 template<
typename,
class>
class Impl,
530 template<
typename>
class HashFunc
532 class PrioritizedMapQueue<
node, P, C, Impl, HashFunc> :
public pq_internal::PrioritizedArrayQueueBase<node, P, C, Impl, NodeArray<typename PrioritizedQueue<node, P, C, Impl>::Handle>>
555 SuperQueue::SuperQueue::clear();
556 this->m_handles.init(*this->m_handles.graphOf(),
nullptr);
564 template<
typename,
class>
class Impl,
565 template<
typename>
class HashFunc
567 class PrioritizedMapQueue<
edge, P, C, Impl, HashFunc> :
public pq_internal::PrioritizedArrayQueueBase<edge, P, C, Impl, EdgeArray<typename PrioritizedQueue<edge, P, C, Impl>::Handle>>
590 SuperQueue::SuperQueue::clear();
591 this->m_handles.init(*this->m_handles.graphOf(),
nullptr);
void pop()
Removes the topmost element from the queue.
Declaration and implementation of HashArray class.
typename SpecImpl::Handle handle
PriorityQueue & operator=(PriorityQueue other)
Copy and move assignment.
Data type for general directed graphs (adjacency list representation).
void push(const E &element, const P &priority)
Adds a new element to the queue.
PriorityQueue(const C &cmp=C(), int initialSize=128)
Creates empty priority queue.
size_type size() const
Returns the number of enqueued elements.
Pairing heap implementation.
void swap(PriorityQueue &other)
Swaps the contents.
Indexed arrays using hashing for element access.
void clear()
Removes all elements from this queue.
typename SuperQueue::handle Handle
The type of handle for accessing the elements of this queue.
PrioritizedMapQueue(const Graph &G, const C &cmp=C(), int initialSize=-1)
Creates a new queue with the given comparer.
Dynamic arrays indexed with edges.
const P & priority(const E &element) const
void clear()
Removes all elements from this queue.
const E & element() const
Defines a queue for handling prioritized elements.
Prioritized queue interface wrapper for heaps.
PriorityQueue(const PriorityQueue &other)
Copy constructor.
Used to compare elements with assigned priorities.
typename PrioritizedQueue< node, P, C, Impl >::Handle Handle
const T & value(handle pos) const
Returns the priority of that handle.
void merge(PriorityQueue &other)
Merges in enqueued values of other queue.
bool operator()(const T &x, const T &y) const
PrioritizedMapQueue(const C &cmp=C(), int initialSize=128)
Creates a new queue with the given comparer.
const value_type & const_reference
PrioritizedQueue(const C &cmp=C(), int initialSize=128)
void decrease(Handle pos, const P &priority)
void push(InputIt first, InputIt last)
Inserts new elements specified by the given range.
Pair for storing an element and a priority.
Dynamic arrays indexed with nodes.
const E & topElement() const
Returns the topmost element in the queue.
Declaration and implementation of EdgeArray class.
Implementation of pairing heap data structure.
void pop()
Removes the top element from the heap.
SpecImpl * m_impl
Underlying heap data structure.
handle push(const value_type &value)
Inserts a new element with given value into the queue.
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
Compare(const C &compare=C())
PrioritizedArrayQueueBase(const C &cmp, int initialSize, const Map &map)
void clear()
Removes all the entries from the queue.
Class for the representation of edges.
friend void swap(PriorityQueue &a, PriorityQueue &b)
Swaps the contents.
PriorityQueue(PriorityQueue &&other)
Move constructor.
Class for the representation of nodes.
Declaration and implementation of NodeArray class.
Priority queue interface wrapper for heaps.
PrioritizedMapQueue(const Graph &G, const C &cmp=C(), int initialSize=-1)
Creates a new queue with the given comparer.
void clear()
Removes all elements from this queue.
const T & top() const
Returns reference to the top element in the queue.
~PriorityQueue()
Destroys the underlying data structure.
void push(std::initializer_list< value_type > ilist)
Inserts new elements specified by the given initializer list.
bool empty() const
Checks whether the queue is empty.
const P & topPriority() const
Returns the priority of the topmost element in this queue.
const P & priority() const
PriorityQueue(std::initializer_list< value_type > init, const C &cmp=C())
Creates priority queue with contents of the given initializer list.
PairTemplate & operator=(const PairTemplate &pair)
bool contains(const E &element) const
Returns whether this queue contains that key.
The namespace for all OGDF objects.
PriorityQueue(InputIt first, InputIt last, const C &cmp=C())
Creates priority queue with contents of the given range.
void decrease(handle pos, const T &value)
Decreases value of the element specified by handle to value.
Handle push(const E &element, const P &priority)
Pushes a new element with the respective priotiy to the queue.
PriorityQueue & operator=(std::initializer_list< value_type > ilist)
Assigns the priority queue contents of the given initializer list.
typename PrioritizedQueue< edge, P, C, Impl >::Handle Handle
PairTemplate(const E &element, const P &priority)
size_type m_size
Number of entries.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.