53 heap =
new int[maxsize];
54 p =
new double[maxsize];
55 pos =
new int[maxId + 1];
59 for ( i = 0; i <= maxId; i++ )
87 int return_value = heap[0];
108 return key <= maxId && pos[key] >= 0;
113 return key <= maxId ? pos[key] : -1;
118 if ( size == maxsize || key > maxId || key < 0 )
136 if ( key < 0 || key > maxId )
146 heap[i] = heap[size];
158 while ( size > pi ) pi *= 2;
162 for ( i = size - 1; i >= 0; i-- )
177 if ( key < 0 || key > maxId )
186 if ( greater( p[
PARENT( i )], p[i] ) )
219 if (
LEFT(
id ) < size )
221 if (
RIGHT(
id ) < size )
226 min_child =
LEFT(
id );
231 if ( greater( p[
id], p[min_child] ) )
233 pos[heap[id]] = min_child;
234 pos[heap[min_child]] = id;
239 heap[id] = heap[min_child];
240 p[id] = p[min_child];
242 heap[min_child] = tmpT;
255 if ( key < 0 || key > maxId )
276 if ( key < 0 || key > maxId )
295 fprintf( stderr,
"Size: %d\nMaxSize: %d\n", size, maxsize );
297 for ( i = 0; i < size; i++ )
300 fprintf( stderr,
"id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
302 fprintf( stderr,
"\n" );
311 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...
bool bigger(double l, double r)
Thrown when trying to access an empty data set.
void decreaseKey(int key)