// delete num old particeles void GvParticle::deleteParticles(int num) { GParticle *p=NULL; int i; if (num<=0) return; // delete num first particles for( ; num>0;num--) { GParticle *pfree=firstPart; if (pfree == NULL) { lastPart=NULL; break; } firstPart = pfree->next; freePart(pfree); numParts--; } // re-alloc id's { for (p=firstPart,i=0;p!=NULL; p= p->next;i++) { p->id=i; } }
void freeIjvBlockDiagAndPart(ijvBlockDiag *bd) { int i; if (bd) { if (bd->blocks) for (i = 0; i < bd->part->numParts; i++) freeIJV(bd->blocks[i]); if (bd->part) freePart(bd->part); cFree(bd); } }
// ------------------------------------------------------------------------ // Simple driver function to test union-find partition algorithm int main( void ) { printf( "Union-find test program\n" "Universe: [0, ..., %i]\n" "Commands: u x y - unions together blocks containing x and y\n" " f x - finds block containing x\n" " p - print partition\n" " . - quit\n", SIZE-1 ); Part pt = newPart( SIZE ); testPartition( pt ); freePart( pt ); printf( "Goodbye!\n" ); }