ScummVM API documentation
Crab::PriorityQueue< Node > Class Template Reference

The open heap used by all cost-based search algorithms. More...

#include <PriorityQueue.h>

Public Member Functions

 PriorityQueue (bool(*)(Node const *, Node const *))
 Constructs a new PriorityQueue that heap-sorts nodes using the specified comparator.
 
bool empty () const
 Returns true if the heap contains no nodes, false otherwise.
 
void clear ()
 Removes all nodes from the heap. More...
 
size_t size () const
 Returns the number of nodes currently in the heap.
 
void push (Node *node)
 Pushes the specified node onto the heap. More...
 
Nodefront () const
 Returns the least costly node in the heap. More...
 
void pop ()
 Removes the least costly node from the heap. More...
 
void remove (Node const *node)
 Removes all instances of the specified node from the heap.
 
void enumerate (Common::Array< Node const *> &sorted) const
 Enumerates all nodes in the heap so far. More...
 

Detailed Description

template<typename Node>
class Crab::PriorityQueue< Node >

The open heap used by all cost-based search algorithms.

This class template is basically a thin wrapper on top of both the std::deque class template and the STL heap operations.

Member Function Documentation

◆ clear()

template<typename Node >
void Crab::PriorityQueue< Node >::clear ( )

Removes all nodes from the heap.

Postcondition

◆ push()

template<typename Node>
void Crab::PriorityQueue< Node >::push ( Node node)

Pushes the specified node onto the heap.

The heap will maintain the ordering of its nodes during this operation.

Postcondition

◆ front()

template<typename Node >
Node * Crab::PriorityQueue< Node >::front ( ) const

Returns the least costly node in the heap.

Precondition

◆ pop()

template<typename Node >
void Crab::PriorityQueue< Node >::pop ( )

Removes the least costly node from the heap.

The heap will maintain the ordering of its nodes during this operation.

Precondition

◆ enumerate()

template<typename Node>
void Crab::PriorityQueue< Node >::enumerate ( Common::Array< Node const *> &  sorted) const

Enumerates all nodes in the heap so far.

Parameters
sortedthe container to which each node will be added.
Precondition
  • There must be no NULL pointers in the heap.
Postcondition
  • All nodes should be sorted by this heap's comparator.

The documentation for this class was generated from the following file: