int main() { int en, de, m; PriorityQueue p; PQ_initialize (&p); PQItem *d, *max; en = PQ_enqueue( 1, &p ); en = PQ_enqueue( 2, &p ); en = PQ_enqueue( 3, &p ); en = PQ_enqueue( 4, &p ); en = PQ_enqueue( 5, &p ); en = PQ_enqueue( 6, &p ); de = PQ_dequeue( d, &p ); de = PQ_dequeue( d, &p ); de = PQ_dequeue( d, &p ); de = PQ_dequeue( d, &p ); de = PQ_dequeue( d, &p ); de = PQ_dequeue( d, &p ); // -1, 3, 30, -123, 30, 2, 4, 5, 6, 40 en = PQ_enqueue( -1, &p ); en = PQ_enqueue( 3, &p ); en = PQ_enqueue( 30, &p ); en = PQ_enqueue( -123, &p ); en = PQ_enqueue( 30, &p ); en = PQ_enqueue( 2, &p ); en = PQ_enqueue( 4, &p ); en = PQ_enqueue( 5, &p ); en = PQ_enqueue( 6, &p ); en = PQ_enqueue( 40, &p ); printf("\n Is empty [%i]\n", PQ_isEmpty( &p )); printf("\n length of queue [%i]\n", PQ_length( &p )); /* int i; for (i = 1; i <= MAXCOUNT; i++) { en = PQ_enqueue( i, &p ); } */ printf("The removed item is -> [%i]\n\n", *d); PQ_print(&p); printf("\n Is empty [%i]\n", PQ_isEmpty( &p )); printf("\n Is full [%i]\n", PQ_isFull( &p )); printf("\n length of queue [%i]\n", PQ_length( &p )); m = PQ_findMax( max,&p ); printf("\n highest priority [%i]\n", *max); system("PAUSE"); exit(EXIT_SUCCESS); }
// // Initialize TIN structure, returns a pointer to lower left tri. This // will not initialize the points in the triangles, just the two // staring triangles. Points will be added later in refinement. // TIN_TILE* initTinTile(TIN_TILE *tt,TIN_TILE *leftTile, TIN_TILE *topTile, TRIANGLE *leftTri, TRIANGLE *topTri, R_POINT *nw, R_POINT *sw, R_POINT *ne, int iOffset, int jOffset, short useNodata, TIN *tin){ // Create a pointer to the lower left tri in the tin TRIANGLE *first, *second; // Create a PQ of the error of the triangles. We want to give the PQ // an initial size which is the lowest power of 2 which will fit all // the triangles in a tile (3 * numPoints in tile) = (3 * tin->tl *tin->tl) // // If TL is larger than 4000 then we are probably running untiled // and we should start the pq small and just let it grow as needed unsigned int initPQSize = 1048576; if(tin->tl < 4000) initPQSize = (unsigned int) pow(2,ceil(log10(3 * tin->tl * tin->tl) /log10(2))); tt->pq = PQ_initialize( initPQSize ); // Set Offset tt->iOffset = iOffset; tt->jOffset = jOffset; // Set neighbors tt->top = topTile; tt->left = leftTile; // Number of triangles and points tt->numTris = 2; tt->numPoints = 4; // Point neighbors to me pointNeighborTileTo(tt,DIR_BOTTOM,topTile); pointNeighborTileTo(tt,DIR_RIGHT,leftTile); // We need to create at least 1 and up to 4 corner points for the // intial triangulation. They have incorrect z value for now and // will be updated later if(nw == NULL){ nw = (R_POINT*)malloc(sizeof(R_POINT)); nw->x=iOffset; nw->y=jOffset; nw->z=0; } if(ne == NULL){ ne = (R_POINT*)malloc(sizeof(R_POINT)); ne->x=iOffset; ne->y=tt->ncols-1+jOffset; ne->z=0; } if(sw == NULL){ sw = (R_POINT*)malloc(sizeof(R_POINT)); sw->x=tt->nrows-1+iOffset; sw->y=jOffset; sw->z=0; } R_POINT *se = (R_POINT*)malloc(sizeof(R_POINT)); se->x=tt->nrows-1+iOffset; se->y=tt->ncols-1+jOffset; se->z=0; // Store the 4 corner points for later reference tt->nw = nw; tt->ne = ne; tt->sw = sw; tt->se = se; assert(pointOnBoundary(nw,tt) && pointOnBoundary(ne,tt) && pointOnBoundary(sw,tt) && pointOnBoundary(se,tt) ); // Create the first two triangles. tt->t = first = addTri(tt,nw,sw,se,leftTri,NULL,NULL); second = addTri(tt,nw,ne,se,topTri,first,NULL); assert(tt->t); assert(first); assert(second); // Point the tins lower left corner to sw tt->v = sw; // Lower left edge nw-sw gets stored in tin tt->e.t1 = NULL; tt->e.t2 = NULL; tt->e.p1 = nw; tt->e.p2 = sw; tt->e.type = IN; return tt; }