50 heap =
new int[maxsize];
51 p =
new double[maxsize];
52 pos =
new int[maxId+1];
56 for ( i = 0; i <= maxId; i++ )
84 int return_value = heap[0];
105 return key <= maxId && pos[key] >= 0;
110 return key <= maxId ? pos[key] : -1;
115 if ( size == maxsize || key > maxId || key < 0 )
133 if ( key < 0 || key > maxId )
143 heap[i] = heap[size];
155 while ( size > pi ) pi *= 2;
159 for ( i = size - 1; i >= 0; i-- )
174 if ( key < 0 || key > maxId )
183 if ( greater( p[
PARENT( i )], p[i] ) )
216 if (
LEFT(
id ) < size )
218 if (
RIGHT(
id ) < size )
223 min_child =
LEFT(
id );
228 if ( greater( p[
id], p[min_child] ) )
230 pos[heap[id]] = min_child;
231 pos[heap[min_child]] = id;
236 heap[id] = heap[min_child];
237 p[id] = p[min_child];
239 heap[min_child] = tmpT;
252 if ( key < 0 || key > maxId )
273 if ( key < 0 || key > maxId )
292 fprintf( stderr,
"Size: %d\nMaxSize: %d\n", size, maxsize );
294 for ( i = 0; i < size; i++ )
297 fprintf( stderr,
"id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
299 fprintf( stderr,
"\n" );
308 for ( i = 0; i < maxsize; i++ )
bool smaller(double l, double r)
Thrown when something is added in a Full set.
void insert(int key, double p)
void setPriority(int key, double new_p)
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...
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
bool bigger(double l, double r)
Thrown when trying to access an empty dada set.
void decreaseKey(int key)