53 heap =
new int[maxsize];
54 p =
new double[maxsize];
55 pos =
new int[maxId + 1];
59 for ( i = 0; i <= maxId; i++ )
87 const 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 )
138 const int i = pos[key];
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 )
258 const int i = pos[key];
276 if ( key < 0 || key > maxId )
279 const int i = pos[key];
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++ )