51 heap =
new int[maxsize];
52 p =
new double[maxsize];
53 pos =
new int[maxId+1];
57 for ( i = 0; i <= maxId; i++ )
85 int return_value = heap[0];
100 heap[0] = heap[size];
111 return key <= maxId && pos[key] >= 0;
116 return key <= maxId ? pos[key] : -1;
121 if ( size == maxsize || key > maxId || key < 0 )
143 if ( key < 0 || key > maxId )
162 heap[i] = heap[size];
174 while ( size > pi ) pi *= 2;
178 for ( i = size - 1; i >= 0; i-- )
193 if ( key < 0 || key > maxId )
202 if ( greater( p[
PARENT( i )], p[i] ) )
235 if (
LEFT(
id ) < size )
237 if (
RIGHT(
id ) < size )
242 min_child =
LEFT(
id );
247 if ( greater( p[
id], p[min_child] ) )
249 pos[heap[id]] = min_child;
250 pos[heap[min_child]] = id;
255 heap[id] = heap[min_child];
256 p[id] = p[min_child];
258 heap[min_child] = tmpT;
271 if ( key < 0 || key > maxId )
292 if ( key < 0 || key > maxId )
311 fprintf( stderr,
"Size: %d\nMaxSize: %d\n", size, maxsize );
313 for ( i = 0; i < size; i++ )
316 fprintf( stderr,
"id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
318 fprintf( stderr,
"\n" );
327 for ( i = 0; i < maxsize; i++ )
Thrown when something is added in a Full set.
void setPriority(int key, double new_p)
bool bigger(double l, double r)
void insert(int key, double p)
bool smaller(double l, double r)
void decreaseKey(int key)
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
PriorityQueue(int n, int maxId, bool min)
Create a priority queue of max size n @param n max size of the queuet @param p external vector repres...
Thrown when trying to access an empty dada set.