15 #include "../../misc/array.hpp" 16 #include "../../misc/hashtable.hpp" 17 #include "../../misc/binaryheap.hpp" 24 template <
class Titem_,
int Thash_bits_open_,
int Thash_bits_closed_>
28 typedef typename Titem_::Key
Key;
56 return m_open.
Count();
62 return m_closed.
Count();
68 if (m_new_node == NULL) m_new_node = m_arr.
AppendC();
76 if (&item == m_new_node) {
85 assert(m_closed.
Find(item.GetKey()) == NULL);
88 if (&item == m_new_node) {
97 return m_open_queue.
Begin();
106 Titem_ *item = m_open_queue.
Shift();
116 Titem_ *item = m_open.
Find(key);
123 Titem_ &item = m_open.
Pop(key);
124 uint idxPop = m_open_queue.
FindIndex(item);
125 m_open_queue.
Remove(idxPop);
132 assert(m_open.
Find(item.GetKey()) == NULL);
139 Titem_ *item = m_closed.
Find(key);
156 template <
class D>
void Dump(D &dmp)
const 158 dmp.WriteStructT(
"m_arr", &m_arr);
CClosedList m_closed
Hash table of pointers to closed item data.
int ClosedCount()
return number of closed nodes
T * Begin()
Get the smallest item in the binary tree.
void Push(Titem_ &new_item)
add one item - copy it from the given item
CItemArray m_arr
Here we store full item data (Titem_).
int OpenCount()
return number of open nodes
CBinaryHeapT< Titem_ > CPriorityQueue
How the priority queue will be managed.
Titem_ * CreateNewNode()
allocate new data item from m_arr
Titem_ & Pop(const Tkey &key)
non-const item search & removal
Titem * m_new_node
New open node under construction.
bool IsEmpty() const
Test if the priority queue is empty.
COpenList m_open
Hash table of pointers to open item data.
CHashTableT< Titem_, Thash_bits_closed_ > CClosedList
How pointers to closed nodes will be stored.
Titem_ * GetBestOpenNode()
return the best open node
SmallArray< Titem_, 65536, 256 > CItemArray
Type that we will use as item container.
Titem_::Key Key
Make Titem_::Key a property of #HashTable.
Titem_ * PopBestOpenNode()
remove and return the best open node
const Titem_ * Find(const Tkey &key) const
const item search
uint Length() const
Return actual number of items.
Titem_ Titem
Make #Titem_ visible from outside of class.
void Dump(D &dmp) const
Helper for creating output of this array.
T * AppendC()
allocate and construct new item
Hash table based node list multi-container class.
CHashTableT< Titem_, Thash_bits_open_ > COpenList
How pointers to open nodes will be stored.
int Count() const
item count
uint FindIndex(const T &item) const
Search for an item in the priority queue.
T * Shift()
Remove and return the smallest (and also first) item from the priority queue.
~CNodeList_HashTableT()
destructor
void FoundBestNode(Titem_ &item)
Notify the nodelist that we don't want to discard the given node.
void Include(T *new_item)
Insert new item into the priority queue, maintaining heap order.
int TotalCount()
The number of items.
Titem_ & ItemAt(int idx)
Get a particular item.
CPriorityQueue m_open_queue
Priority queue of pointers to open item data.
CNodeList_HashTableT()
default constructor
void InsertOpenNode(Titem_ &item)
insert given item as open node (into m_open and m_open_queue)
Titem_ * FindOpenNode(const Key &key)
return the open node specified by a key or NULL if not found
void Remove(uint index)
Remove item at given index from the priority queue.
Titem_ * FindClosedNode(const Key &key)
return the closed 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