10 #ifndef STOPRIQUE3_H_INCLUDED_PREDOEHL_UOFARIZONAVISION
11 #define STOPRIQUE3_H_INCLUDED_PREDOEHL_UOFARIZONAVISION 1
13 #include <l/l_sys_lib.h>
14 #include <l/l_sys_rand.h>
127 template<
typename SATELLITE_TYPE,
int POWERLAW_NUM,
int POWERLAW_DEN >
180 : dat( sat ), spqloc( bxl )
200 : subq( pq ), loc( pl ), sat( ps ), enr( pe )
210 bool is_cleared()
const
217 std::vector< Compo > m_master;
242 Key_tp DUMMY_WT() {
return 0; }
251 static inline Key_tp energy2weight(
const Key_tp& energy )
268 return 0 < enr && enr < MAX_ENERGY() ? energy2weight(enr) : DUMMY_WT();
274 inline RBT& which_sub_queue(
const Key_tp& energy )
280 if ( MAX_ENERGY() <= energy )
291 SatLoc satloc( sat, LOC_BIAS + m_master.size() );
292 Loc_tp inner_loc = subq.insert( nice_e2w( energy ), satloc );
293 m_master.push_back( Compo( & subq, inner_loc, sat, energy ) );
294 return satloc.spqloc;
299 Compo* ref(
Loc_tp spqloc )
301 if ( spqloc < LOC_BIAS )
305 register Loc_tp unbiased = spqloc - LOC_BIAS;
306 return m_master.size() <= unbiased ? 00 : & m_master[ unbiased ];
311 const Compo* ref(
Loc_tp spqloc )
const
313 if ( spqloc < LOC_BIAS )
317 register Loc_tp unbiased = spqloc - LOC_BIAS;
318 return m_master.size() <= unbiased ? 00 : & m_master[ unbiased ];
328 return m_always.
size() + m_sometimes.
size() + m_never.
size();
352 return insert_here( m_never, sat, MAX_ENERGY() );
359 return insert_here( which_sub_queue( energy ), sat, energy );
366 const Compo* ccc = ref( spqloc );
367 if ( 00 == ccc || ccc -> is_cleared() )
373 *energy = ccc -> enr;
377 *serialnum = ccc -> sat;
386 Compo* ccc = ref( spqloc );
387 if ( 00 == ccc || ccc -> is_cleared() )
391 bool result = ccc -> subq ->
erase_loc( ccc -> loc );
400 Compo* ccc = ref( spqloc );
401 if ( 00 == ccc || ccc -> is_cleared() )
405 register const Key_tp oldenergy = ccc -> enr;
406 if ( newenergy == oldenergy )
410 ccc -> enr = newenergy;
413 const Key_tp new_weight = nice_e2w( newenergy );
414 RBT& newsubq = which_sub_queue( newenergy );
415 if ( & newsubq == ccc -> subq )
417 return ccc -> subq ->
rekey_loc( ccc -> loc, new_weight );
421 bool result = ccc -> subq ->
erase_loc( ccc -> loc );
422 ccc -> subq = & newsubq;
424 = ccc -> subq ->
insert( new_weight, SatLoc( ccc -> sat, spqloc ));
456 const bool alwaysland_empty = m_always.
is_empty();
457 if ( alwaysland_empty && m_sometimes.
is_empty() )
461 const RBT& pq( alwaysland_empty ? m_sometimes : m_always );
463 if ( alwaysland_empty )
501 const bool alwaysland_empty = m_always.
is_empty();
502 if ( alwaysland_empty && m_sometimes.
is_empty() )
506 const RBT& pq( alwaysland_empty ? m_sometimes : m_always );
a priority queue implementing a stochastic extract-near-min method
Definition: stoprique.h:128
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
bool erase_loc(Loc_tp spqloc)
remove the indicated record
Definition: stoprique.h:384
bool access_loc(Loc_tp spqloc, Key_tp *energy, Sat_tp *serialnum) const
fetch the energy or satellite values of indicated record
Definition: stoprique.h:364
size_t size() const
return the number of key+value pairs in the dictionary.
Definition: redblack.h:2794
Loc_tp loc_min() const
get the locator of the record with maximum probability weight
Definition: stoprique.h:499
DijkstraPriorityQueue< SATELLITE_TYPE >::Key_tp Key_tp
alias of key type
Definition: stoprique.h:137
bool is_empty() const
predicate tests whether the queue contains no entries
Definition: stoprique.h:333
#define KJB(x)
Definition: l_util.h:9
Loc_tp ins_max_key(const Sat_tp &sat)
insert a key with infinite energy (must be relaxed before drawn)
Definition: stoprique.h:350
bool access_loc(Loc_tp query_loc, Key_tp *key_out, Sat_tp *sat_out) const
access a record via its locator, a constant-time operation.
Definition: redblack.h:2695
#define ASSERT(condition, message)
Definition: Assert.h:45
pure virtual interface for priority queue in Dijkstra's algorithm
Definition: diprique.h:72
SATELLITE_TYPE Sat_tp
alias of satellite type
Definition: stoprique.h:134
DijkstraPriorityQueue< SATELLITE_TYPE >::Loc_tp Loc_tp
alias of locator type
Definition: stoprique.h:140
Loc_tp loc_max() const
return the locator for the record with the maximum key, or 0
Definition: redblack.h:2787
Loc_tp loc_using_cumulative_key_sum(Key_tp cumulative_keysum) const
fetch a node based on inorder cumulative sum of tree keys
Definition: redblack.h:2929
size_t size() const
return the number of (valid) entries in the queue
Definition: stoprique.h:326
void clear()
destroy the tree or the linear array.
Definition: redblack.h:2442
float Key_tp
type that we use for keys
Definition: diprique.h:75
Loc_tp Dijkstra_extraction() const
method to make this and deterministic pri queue share interface
Definition: stoprique.h:536
definition of class Redblack_subtree_sum.
bool is_empty() const
return whether the size is zero
Definition: redblack.h:2801
void clear()
throw away all contents
Definition: stoprique.h:340
size_t Loc_tp
type that we use for locators
Definition: diprique.h:76
SATELLITE_TYPE Sat_tp
type of satellite data
Definition: diprique.h:74
Loc_tp insert(const Key_tp &energy, const Sat_tp &sat)
insert a key with a given energy and a given satellite value
Definition: stoprique.h:357
a good external locator is always positive, this isn't
Definition: stoprique.h:169
Loc_tp low_energy_sample() const
get the locator of a record drawn by our devious method
Definition: stoprique.h:454
bool rekey_loc(Loc_tp spqloc, const Key_tp &newenergy)
change the energy of the indicated record
Definition: stoprique.h:398
Key_tp root_sum() const
return subtree sum at root node (i.e., the sum of all keys).
Definition: redblack.h:2885
static Key_tp power_law()
parameter used in the energy ~ probability weight relation
Definition: stoprique.h:163