Support Forum       G3D Web Page     
Classes | Public Member Functions | List of all members
G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value > Class Template Reference

An inefficient implementation of a priority queue. More...

Public Member Functions

void insert (const Key &k, const Value &v, float cost)
 
int length () const
 
Value removeMin ()
 Returns the minimum cost value in O(n) time in the length of the queue. More...
 
void update (const Key &k, float cost)
 Update the cost of value N. More...
 

Detailed Description

template<typename Node, class HashFunc = HashTrait<Node>>
template<class Key, class Value>
class G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value >

An inefficient implementation of a priority queue.

A heap data structure would make a more asymptotically efficient implementation at the cost of some implementation complexity. For short queues the difference is not significant, but for long queues the performance difference is O(n) vs. O(log n) for the removeMin operation. The advantage of this implementation is that we avoid complexity in the update() call, which must be backed by a hash table in any case for efficiency but which requires a more complex tree traversal if a heap is used.

Member Function Documentation

◆ insert()

template<typename Node , class HashFunc = HashTrait<Node>>
template<class Key, class Value>
void G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value >::insert ( const Key &  k,
const Value &  v,
float  cost 
)
inline

◆ length()

template<typename Node , class HashFunc = HashTrait<Node>>
template<class Key, class Value>
int G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value >::length ( ) const
inline

◆ removeMin()

template<typename Node , class HashFunc = HashTrait<Node>>
template<class Key, class Value>
Value G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value >::removeMin ( )
inline

Returns the minimum cost value in O(n) time in the length of the queue.

Referenced by G3D::Pathfinder< Node, HashFunc >::findPath().

◆ update()

template<typename Node , class HashFunc = HashTrait<Node>>
template<class Key, class Value>
void G3D::Pathfinder< Node, HashFunc >::PriorityQueue< Key, Value >::update ( const Key &  k,
float  cost 
)
inline

Update the cost of value N.

Referenced by G3D::Pathfinder< Node, HashFunc >::findPath().


documentation generated on Wed Nov 24 2021 08:01:59 using doxygen 1.8.15