55 heap =
new int[maxsize];
56 p =
new double[maxsize];
57 pos =
new int[maxId+1];
61 for ( i = 0; i <= maxId; i++ )
89 int return_value = heap[0];
104 heap[0] = heap[size];
115 return key <= maxId && pos[key] >= 0;
120 return key <= maxId ? pos[key] : -1;
125 if ( size == maxsize || key > maxId || key < 0 )
147 if ( key < 0 || key > maxId )
166 heap[i] = heap[size];
178 while ( size > pi ) pi *= 2;
182 for ( i = size - 1; i >= 0; i-- )
197 if ( key < 0 || key > maxId )
206 if ( greater( p[
PARENT( i )], p[i] ) )
239 if (
LEFT(
id ) < size )
241 if (
RIGHT(
id ) < size )
246 min_child =
LEFT(
id );
251 if ( greater( p[
id], p[min_child] ) )
253 pos[heap[id]] = min_child;
254 pos[heap[min_child]] = id;
259 heap[id] = heap[min_child];
260 p[id] = p[min_child];
262 heap[min_child] = tmpT;
275 if ( key < 0 || key > maxId )
296 if ( key < 0 || key > maxId )
315 fprintf( stderr,
"Size: %d\nMaxSize: %d\n", size, maxsize );
317 for ( i = 0; i < size; i++ )
320 fprintf( stderr,
"id: %7d -> key: %7d -> id: %7d p: %7f\n", i, heap[i], pos[heap[i]], p[i] );
322 fprintf( stderr,
"\n" );
331 for ( i = 0; i < maxsize; i++ )