ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::TableHeap< T, D > Class Template Reference

the ids \( [ 0 , n ) \) in a \( D \)-ary heap by the keys that the table T holds for them, read from it by update( id ): the queue of the frontier as an observer of the table of a search, in the form of the LaB-PQ of Dong et al. More...

#include <ADS/priority/IndexedDaryHeap.h>

Public types

using Key
 the type of the keys, those of the table
using Item = int
 the items: the ids
using Priority = Key
 and their priorities, the keys
using Handle = int
 the id itself

Public member functions

 TableHeap (const T &t, int n=0)
 the empty queue of the ids \( [ 0 , n ) \) of the table \( t \), which must outlive it
void update (int id)
 the id in the queue with its key in the table, inserted or moved, the ids raised to \( \mathit{id} + 1 \) if fewer
void erase (int id)
 the id out of the queue, if it is there
bool contains (int id) const
 whether the id is in the queue
bool empty (void) const
 whether the queue is empty
std::size_t size (void) const
 the number of ids in the queue
const Key & key (int id) const
 the key of an id in the queue, as read last from the table
int min (void) const
 the id of least key
int deleteMin (void)
 removes the id of least key and returns it
void extract (const Key &theta, std::vector< int > &out)
 every id of key at most \( \theta \) appended to out, by increasing keys, each removed
void clear (void)
 the queue emptied
void refresh (void)
 the ids that the table no longer has taken out, and the keys of the others read again, in \( O( s ) \) time
const IndexedDaryHeap< Key, D > & heap (void) const
 the heap, for the reads
template<class H, class V>
void on (const mod::Changed< mod::Value, H, V > &e)
 a value of the table written: its id updated
template<class H, class K, class V>
void on (const mod::Inserted< H, K, V > &e)
 a value of the table inserted: its id updated
template<class H, class K, class V>
void on (const mod::Erased< H, K, V > &e) noexcept
 a value of the table erased: its id out of the queue
void on (const mod::Cleared &) noexcept
 the table emptied: the queue too
void on (const mod::Rebuilt &) noexcept
 the table rebuilt: refresh()

Detailed description

template<class T, unsigned D = 4>
class ADS::TableHeap< T, D >

the ids \( [ 0 , n ) \) in a \( D \)-ary heap by the keys that the table T holds for them, read from it by update( id ): the queue of the frontier as an observer of the table of a search, in the form of the LaB-PQ of Dong et al.

The table is anything that t[ id ] reads and t.size() measures (a std::vector, an ObservableArray [see ObservableArray.h]); the queue copies the key of an id when it reads it, and update( id ) makes the id enter the queue with its present key, or move to it, in \( O( D \log_D s ) \) time, so that a search that writes the table calls update() on the ids it wrote, or attaches the queue to an observable table, whose Assigned and Inserted call it, Erased takes the id out, Cleared empties the queue and Rebuilt reads the keys of all its ids again. extract( theta , out ) takes every id of key at most \( \theta \), as the stepping algorithms do. Unlike the tournament tree of the paper, the queue updates an id at once instead of marking it for the next extraction, which costs a logarithm per update and gives the same ids to each extract().

See also
X. Dong, Y. Gu, Y. Sun, Y. Zhang, Efficient stepping algorithms and implementations for parallel shortest paths, Proceedings of SPAA, 184-197, 2021, doi:10.1145/3409964.3461782

Member typedef documentation

◆ Handle

template<class T, unsigned D = 4>
using ADS::TableHeap< T, D >::Handle = int

the id itself

◆ Item

template<class T, unsigned D = 4>
using ADS::TableHeap< T, D >::Item = int

the items: the ids

◆ Key

template<class T, unsigned D = 4>
using ADS::TableHeap< T, D >::Key
Initial value:
std::remove_cvref_t<
decltype( std::declval< const T & >()[ std::size_t() ] ) >

the type of the keys, those of the table

◆ Priority

template<class T, unsigned D = 4>
using ADS::TableHeap< T, D >::Priority = Key

and their priorities, the keys

Constructor and destructor documentation

◆ TableHeap()

template<class T, unsigned D = 4>
ADS::TableHeap< T, D >::TableHeap ( const T & t,
int n = 0 )
inlineexplicit

the empty queue of the ids \( [ 0 , n ) \) of the table \( t \), which must outlive it

Precondition
\( n \ge 0 \)

Member function documentation

◆ clear()

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::clear ( void )
inline

the queue emptied

◆ contains()

template<class T, unsigned D = 4>
bool ADS::TableHeap< T, D >::contains ( int id) const
inlinenodiscard

whether the id is in the queue

◆ deleteMin()

template<class T, unsigned D = 4>
int ADS::TableHeap< T, D >::deleteMin ( void )
inline

removes the id of least key and returns it

Precondition
the queue is not empty

◆ empty()

template<class T, unsigned D = 4>
bool ADS::TableHeap< T, D >::empty ( void ) const
inlinenodiscard

whether the queue is empty

◆ erase()

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::erase ( int id)
inline

the id out of the queue, if it is there

◆ extract()

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::extract ( const Key & theta,
std::vector< int > & out )
inline

every id of key at most \( \theta \) appended to out, by increasing keys, each removed

◆ heap()

template<class T, unsigned D = 4>
const IndexedDaryHeap< Key, D > & ADS::TableHeap< T, D >::heap ( void ) const
inlinenodiscard

the heap, for the reads

◆ key()

template<class T, unsigned D = 4>
const Key & ADS::TableHeap< T, D >::key ( int id) const
inlinenodiscard

the key of an id in the queue, as read last from the table

Precondition
the id is in the queue

◆ min()

template<class T, unsigned D = 4>
int ADS::TableHeap< T, D >::min ( void ) const
inlinenodiscard

the id of least key

Precondition
the queue is not empty

◆ on() [1/5]

template<class T, unsigned D = 4>
template<class H, class V>
void ADS::TableHeap< T, D >::on ( const mod::Changed< mod::Value, H, V > & e)
inline

a value of the table written: its id updated

◆ on() [2/5]

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::on ( const mod::Cleared & )
inlinenoexcept

the table emptied: the queue too

◆ on() [3/5]

template<class T, unsigned D = 4>
template<class H, class K, class V>
void ADS::TableHeap< T, D >::on ( const mod::Erased< H, K, V > & e)
inlinenoexcept

a value of the table erased: its id out of the queue

◆ on() [4/5]

template<class T, unsigned D = 4>
template<class H, class K, class V>
void ADS::TableHeap< T, D >::on ( const mod::Inserted< H, K, V > & e)
inline

a value of the table inserted: its id updated

◆ on() [5/5]

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::on ( const mod::Rebuilt & )
inlinenoexcept

the table rebuilt: refresh()

◆ refresh()

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::refresh ( void )
inline

the ids that the table no longer has taken out, and the keys of the others read again, in \( O( s ) \) time

◆ size()

template<class T, unsigned D = 4>
std::size_t ADS::TableHeap< T, D >::size ( void ) const
inlinenodiscard

the number of ids in the queue

◆ update()

template<class T, unsigned D = 4>
void ADS::TableHeap< T, D >::update ( int id)
inline

the id in the queue with its key in the table, inserted or moved, the ids raised to \( \mathit{id} + 1 \) if fewer

Precondition
\( 0 \le \mathit{id} < \) t.size()

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