HP-MPI User's Guide (11th Edition)

Example applications
sort.C
Appendix A270
*numOfEntries_p = numOfEntries;
//
// Add in the left and right shadow entries.
//
numOfEntries += 2;
//
// Allocate space for the entries and use rand to initialize
the values.
//
entries = new Entry *[numOfEntries];
for(int i = 1; i < numOfEntries-1; i++) {
entries[i] = new Entry;
*(entries[i]) = (rand()%1000) * ((rand()%2 == 0)? 1 :
-1);
}
//
// Initialize the shadow entries.
//
entries[0] = new Entry(MINENTRY);
entries[numOfEntries-1] = new Entry(MAXENTRY);
}
//
//BlockOfEntries::~BlockOfEntries
//
//Function:- delete the block of entries.
//
BlockOfEntries::~BlockOfEntries()
{
for(int i = 1; i < numOfEntries-1; i++) {
delete entries[i];
}
delete entries[0];
delete entries[numOfEntries-1];
delete [] entries;
}
//