OpenTTD
Public Types | Public Member Functions | Protected Attributes
CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ > Class Template Reference

Hash table based node list multi-container class. More...

#include <nodelist.hpp>

Public Types

typedef Titem_ Titem
 Make #Titem_ visible from outside of class.
typedef Titem_::Key Key
 Make Titem_::Key a property of #HashTable.
typedef SmallArray< Titem_, 65536, 256 > CItemArray
 Type that we will use as item container.
typedef CHashTableT< Titem_,
Thash_bits_open_ > 
COpenList
 How pointers to open nodes will be stored.
typedef CHashTableT< Titem_,
Thash_bits_closed_ > 
CClosedList
 How pointers to closed nodes will be stored.
typedef CBinaryHeapT< Titem_ > CPriorityQueue
 How the priority queue will be managed.

Public Member Functions

 CNodeList_HashTableT ()
 default constructor
 ~CNodeList_HashTableT ()
 destructor
int OpenCount ()
 return number of open nodes
int ClosedCount ()
 return number of closed nodes
Titem_ * CreateNewNode ()
 allocate new data item from m_arr
void FoundBestNode (Titem_ &item)
 Notify the nodelist that we don't want to discard the given node.
void InsertOpenNode (Titem_ &item)
 insert given item as open node (into m_open and m_open_queue)
Titem_ * GetBestOpenNode ()
 return the best open node
Titem_ * PopBestOpenNode ()
 remove and return the best open node
Titem_ * FindOpenNode (const Key &key)
 return the open node specified by a key or NULL if not found
Titem_ & PopOpenNode (const Key &key)
 remove and return the open node specified by a key
void InsertClosedNode (Titem_ &item)
 close node
Titem_ * FindClosedNode (const Key &key)
 return the closed node specified by a key or NULL if not found
int TotalCount ()
 The number of items.
Titem_ & ItemAt (int idx)
 Get a particular item.
template<class D >
void Dump (D &dmp) const
 Helper for creating output of this array.

Protected Attributes

CItemArray m_arr
 Here we store full item data (Titem_).
COpenList m_open
 Hash table of pointers to open item data.
CClosedList m_closed
 Hash table of pointers to closed item data.
CPriorityQueue m_open_queue
 Priority queue of pointers to open item data.
Titemm_new_node
 New open node under construction.

Detailed Description

template<class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
class CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >

Hash table based node list multi-container class.

Implements open list, closed list and priority queue for A-star path finder.

Definition at line 25 of file nodelist.hpp.

Member Function Documentation

template<class Titem_ , int Thash_bits_open_, int Thash_bits_closed_>
template<class D >
void CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::Dump ( D &  dmp) const
inline

Helper for creating output of this array.

Definition at line 156 of file nodelist.hpp.

References CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::m_arr.

template<class Titem_ , int Thash_bits_open_, int Thash_bits_closed_>
void CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::FoundBestNode ( Titem_ &  item)
inline

Notify the nodelist that we don't want to discard the given node.

Definition at line 73 of file nodelist.hpp.

References CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::m_new_node.

template<class Titem_ , int Thash_bits_open_, int Thash_bits_closed_>
Titem_& CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::ItemAt ( int  idx)
inline

Get a particular item.

Definition at line 150 of file nodelist.hpp.

References CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::m_arr.

template<class Titem_ , int Thash_bits_open_, int Thash_bits_closed_>
int CNodeList_HashTableT< Titem_, Thash_bits_open_, Thash_bits_closed_ >::TotalCount ( )
inline

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