21#ifndef __PBeFS_ads_OpenList
22 #define __PBeFS_ads_OpenList
33#include "ADS/priority/BucketQueue.h"
35#include "ADS/priority/DaryHeap.h"
51template<
class NodeT ,
unsigned Arity = 4 >
54 using Cost =
decltype( NodeT::g );
60 void push( NodeT * node ) {
push( node , node->g ); }
64 void push( NodeT * node , Cost g ) {
65 f_heap.push( Item{ g + node->h , g , node } );
76 [[nodiscard]] Cost
top_f(
void )
const {
return( f_heap.top().f ); }
81 const Item x = f_heap.pop();
87 [[nodiscard]]
bool empty(
void )
const noexcept {
88 return( f_heap.empty() );
93 [[nodiscard]] std::size_t
size(
void )
const noexcept {
94 return( f_heap.size() );
108 bool operator()(
const Item & a ,
const Item & b )
const noexcept {
109 return( ( a.f < b.f ) || ( ( a.f == b.f ) && ( a.g > b.g ) ) );
113 ADS::DaryHeap< Item , Better , Arity > f_heap;
121template<
class NodeT >
124 using Cost =
decltype( NodeT::g );
126 static_assert( std::is_integral_v< Cost > ,
127 "BucketOpenList requires an integer cost type" );
133 void push( NodeT * node ) {
push( node , node->g ); }
137 void push( NodeT * node , Cost g ) { f_queue.push( node , g + node->h , g ); }
147 [[nodiscard]] Cost
top_f(
void ) {
return( f_queue.topF() ); }
152 const auto e = f_queue.popEntry();
158 [[nodiscard]]
bool empty(
void )
const noexcept {
159 return( f_queue.empty() );
164 [[nodiscard]] std::size_t
size(
void )
const noexcept {
165 return( f_queue.size() );
170 ADS::BucketQueue< NodeT * , Cost > f_queue;
Header file for the priority queues of the OPEN list, taken from the set of data structures chosen [s...
the OPEN list on the BucketQueue of ADS, for integer costs
Definition OpenList.h:122
Cost top_f(void)
the f of top()
Definition OpenList.h:147
void push(NodeT *node)
pushes a node with its current f and g
Definition OpenList.h:133
std::size_t size(void) const noexcept
the number of entries, the stale ones included
Definition OpenList.h:164
void push(NodeT *node, Cost g)
pushes a node with the given g (and f = g + h), not reading node->g
Definition OpenList.h:137
OpenEntry< NodeT > pop(void)
removes and returns top()
Definition OpenList.h:151
bool empty(void) const noexcept
true if there is no entry
Definition OpenList.h:158
OpenEntry< NodeT > top(void)
the entry with the smallest f (and the largest g among those)
Definition OpenList.h:141
the OPEN list on the DaryHeap of ADS
Definition OpenList.h:52
Cost top_f(void) const
the f of top()
Definition OpenList.h:76
void push(NodeT *node)
pushes a node with its current f and g
Definition OpenList.h:60
std::size_t size(void) const noexcept
the number of entries, the stale ones included
Definition OpenList.h:93
void push(NodeT *node, Cost g)
pushes a node with the given g (and f = g + h), not reading node->g
Definition OpenList.h:64
OpenEntry< NodeT > pop(void)
removes and returns top()
Definition OpenList.h:80
OpenEntry< NodeT > top(void) const
the entry with the smallest f (and the largest g among those)
Definition OpenList.h:70
bool empty(void) const noexcept
true if there is no entry
Definition OpenList.h:87
namespace for the Parallel Best-First Search library
Definition AStar.h:83
an entry of the OPEN list: the node and the g it had when pushed
Definition OpenList.h:73