ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::lemon_interop::MonotoneHeap< Q, PR, IM > Class Template Reference

a monotone queue of ADS without decrease-key, Q either DialQueue< int , K > or RadixHeap< int , K >, as a heap of LEMON by the lazy deletion More...

#include <ADS/interop/lemon/Heaps.h>

Public types

enum  State { IN_HEAP = 0 , PRE_HEAP = -1 , POST_HEAP = -2 }
 the states of an item, those of LEMON More...
using ItemIntMap = IM
 the cross-reference map
using Prio = PR
 the priorities
using Item = typename IM::Key
 the items
using Pair = std::pair< Item , Prio >
 an item with its priority

Public member functions

 MonotoneHeap (ItemIntMap &m)
 the empty heap on the map \( m \)
template<class C>
 MonotoneHeap (ItemIntMap &m, const C &)
 the empty heap on the map \( m \), the comparator, which must be std::less, not kept
int size (void) const
 the number of items
bool empty (void) const
 whether there is no item
void clear (void)
 all the items removed, the map left as it is
void push (const Item &i, const Prio &p)
 inserts \( i \) with the priority \( p \), in a new slot
void push (const Pair &x)
 inserts the pair \( x \)
Item top (void) const
 the item of least priority
Prio prio (void) const
 the least priority
void pop (void)
 removes the item of least priority, POST_HEAP from now on
Prio operator[] (const Item &i) const
 the priority of the item \( i \)
void decrease (const Item &i, const Prio &p)
 the priority of \( i \) set to \( p \) by a new copy, the old one stale
void increase (const Item &i, const Prio &p)
 as decrease(): the copy of the smaller priority goes stale
void erase (const Item &i)
 removes the item \( i \), if it is in the heap; its copies go stale
void set (const Item &i, const Prio &p)
 the priority of \( i \) set to \( p \), inserting it if needed
State state (const Item &i) const
 the state of the item \( i \), read from the map
void state (const Item &i, State st)
 the state of \( i \) set to \( st \), removing it from the heap if it was there; IN_HEAP changes nothing

Detailed description

template<class Q, class PR, class IM>
class ADS::lemon_interop::MonotoneHeap< Q, PR, IM >

a monotone queue of ADS without decrease-key, Q either DialQueue< int , K > or RadixHeap< int , K >, as a heap of LEMON by the lazy deletion

Member typedef documentation

◆ Item

template<class Q, class PR, class IM>
using ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::Item = typename IM::Key

the items

◆ ItemIntMap

template<class Q, class PR, class IM>
using ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::ItemIntMap = IM

the cross-reference map

◆ Pair

template<class Q, class PR, class IM>
using ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::Pair = std::pair< Item , Prio >

an item with its priority

◆ Prio

template<class Q, class PR, class IM>
using ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::Prio = PR

the priorities

Member enumeration documentation

◆ State

template<class Q, class PR, class IM>
enum ADS::lemon_interop::MonotoneHeap::State

the states of an item, those of LEMON

Enumerator
IN_HEAP 
PRE_HEAP 
POST_HEAP 

Constructor and destructor documentation

◆ MonotoneHeap() [1/2]

template<class Q, class PR, class IM>
ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::MonotoneHeap ( ItemIntMap & m)
inlineexplicit

the empty heap on the map \( m \)

◆ MonotoneHeap() [2/2]

template<class Q, class PR, class IM>
template<class C>
ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::MonotoneHeap ( ItemIntMap & m,
const C &  )
inline

the empty heap on the map \( m \), the comparator, which must be std::less, not kept

Member function documentation

◆ clear()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::clear ( void )
inline

all the items removed, the map left as it is

◆ decrease()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::decrease ( const Item & i,
const Prio & p )
inline

the priority of \( i \) set to \( p \) by a new copy, the old one stale

Precondition
\( i \) is in the heap, \( p \) not less than the last priority popped

◆ empty()

template<class Q, class PR, class IM>
bool ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::empty ( void ) const
inlinenodiscard

whether there is no item

◆ erase()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::erase ( const Item & i)
inline

removes the item \( i \), if it is in the heap; its copies go stale

◆ increase()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::increase ( const Item & i,
const Prio & p )
inline

as decrease(): the copy of the smaller priority goes stale

Precondition
as decrease()

◆ operator[]()

template<class Q, class PR, class IM>
Prio ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::operator[] ( const Item & i) const
inlinenodiscard

the priority of the item \( i \)

Precondition
\( i \) is in the heap

◆ pop()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::pop ( void )
inline

removes the item of least priority, POST_HEAP from now on

Precondition
the heap is not empty

◆ prio()

template<class Q, class PR, class IM>
Prio ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::prio ( void ) const
inlinenodiscard

the least priority

Precondition
the heap is not empty

◆ push() [1/2]

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::push ( const Item & i,
const Prio & p )
inline

inserts \( i \) with the priority \( p \), in a new slot

Precondition
\( i \) is not in the heap, \( p \ge 0 \) not less than the last priority popped

◆ push() [2/2]

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::push ( const Pair & x)
inline

inserts the pair \( x \)

Precondition
as push()

◆ set()

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::set ( const Item & i,
const Prio & p )
inline

the priority of \( i \) set to \( p \), inserting it if needed

◆ size()

template<class Q, class PR, class IM>
int ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::size ( void ) const
inlinenodiscard

the number of items

◆ state() [1/2]

template<class Q, class PR, class IM>
State ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::state ( const Item & i) const
inlinenodiscard

the state of the item \( i \), read from the map

◆ state() [2/2]

template<class Q, class PR, class IM>
void ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::state ( const Item & i,
State st )
inline

the state of \( i \) set to \( st \), removing it from the heap if it was there; IN_HEAP changes nothing

◆ top()

template<class Q, class PR, class IM>
Item ADS::lemon_interop::MonotoneHeap< Q, PR, IM >::top ( void ) const
inlinenodiscard

the item of least priority

Precondition
the heap is not empty

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