-
Notifications
You must be signed in to change notification settings - Fork 16
Open

Description
my optimization
int NUM_ELEMENTS = 0;
// Get a pointer to an array
apultra_arrival** pDestSlotsPtr = &pDestSlots;
// Size of the entire pointer array
size_t arraySize = sizeof(*pDestSlotsPtr);
// Size of one pointer
size_t elemSize = sizeof(*pDestSlotsPtr[0]);
// Calculate the number of elements
NUM_ELEMENTS = arraySize / elemSize;
int left = 0;
int right = NUM_ELEMENTS - 1; // NUM_ELEMENTS - size of the pDestSlots array
while (left <= right) {
int mid = left + (right - left) / 2;
if (pDestSlots[mid].cost < nCodingChoiceCost) {
left = mid + 1;
}
else {
right = mid - 1;
}
}
int n = left; // found index
after this code
if (nCodingChoiceCost < pDestSlots[nArrivalsPerPosition - 1].cost ||
(nCodingChoiceCost == pDestSlots[nArrivalsPerPosition - 1].cost && nScore < pDestSlots[nArrivalsPerPosition - 1].score &&
nRepOffset != pDestSlots[nArrivalsPerPosition - 1].rep_offset)) {
int exists = 0;
Metadata
Metadata
Assignees
Labels
No labels