OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
13 #include "../../misc/hashtable.hpp"
14 #include "../../misc/binaryheap.hpp"
21 template <
class Titem_,
int Thash_bits_open_,
int Thash_bits_closed_>
25 typedef typename Titem_::Key
Key;
129 assert(
m_open.
Find(item.GetKey()) ==
nullptr);
143 return m_arr.Length();
153 template <
class D>
void Dump(D &dmp)
const
155 dmp.WriteStructT(
"m_arr", &
m_arr);
Titem_ * GetBestOpenNode()
return the best open node
T * Shift()
Remove and return the smallest (and also first) item from the priority queue.
CItemArray m_arr
Here we store full item data (Titem_).
Titem_ & PopOpenNode(const Key &key)
remove and return the open node specified by a key
Titem_ & Pop(const Tkey &key)
non-const item search & removal
int OpenCount()
return number of open nodes
bool IsEmpty() const
Test if the priority queue is empty.
void Dump(D &dmp) const
Helper for creating output of this array.
Titem_ * FindClosedNode(const Key &key)
return the closed node specified by a key or nullptr if not found
CHashTableT< Titem_, Thash_bits_open_ > COpenList
How pointers to open nodes will be stored.
const Titem_ * Find(const Tkey &key) const
const item search
CClosedList m_closed
Hash table of pointers to closed item data.
int ClosedCount()
return number of closed nodes
Titem * m_new_node
New open node under construction.
CPriorityQueue m_open_queue
Priority queue of pointers to open item data.
void FoundBestNode(Titem_ &item)
Notify the nodelist that we don't want to discard the given node.
Hash table based node list multi-container class.
int Count() const
item count
Titem_ & ItemAt(int idx)
Get a particular item.
size_t FindIndex(const T &item) const
Search for an item in the priority queue.
Titem_::Key Key
Make Titem_::Key a property of this class.
void InsertClosedNode(Titem_ &item)
close node
Titem_ * FindOpenNode(const Key &key)
return the open node specified by a key or nullptr if not found
Titem_ * PopBestOpenNode()
remove and return the best open node
void Remove(size_t index)
Remove item at given index from the priority queue.
void InsertOpenNode(Titem_ &item)
insert given item as open node (into m_open and m_open_queue)
~CNodeList_HashTableT()
destructor
int TotalCount()
The number of items.
COpenList m_open
Hash table of pointers to open item data.
void Include(T *new_item)
Insert new item into the priority queue, maintaining heap order.
CHashTableT< Titem_, Thash_bits_closed_ > CClosedList
How pointers to closed nodes will be stored.
std::deque< PathNode > CItemArray
Type that we will use as item container.
Titem_ Titem
Make #Titem_ visible from outside of class.
CBinaryHeapT< Titem_ > CPriorityQueue
How the priority queue will be managed.
T * Begin()
Get the smallest item in the binary tree.
Titem_ * CreateNewNode()
allocate new data item from m_arr
void Push(Titem_ &new_item)
add one item - copy it from the given item
CNodeList_HashTableT()
default constructor