View Single Post
Old Apr 3rd, 2007, 11:39 PM   #3
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
Hm... it depends a little on how you're going to operate. If you were to sort the entire list each time you made a decision, you could do something like the following:
void someComparisonBasedSort(processDataType pdt [], size_t len, int (*compare)(processDataType, processDataType))
where compare would be a function pointer used to determine the relative values of its parameters based on however you want. So you could have one function, compareByTotalTime(processDataType, processDataType) which would return an int for the comparison result and call your sort by passing &compareByTotalTime.

Another way to do it is to keep the list of processes sorted as you add processes to the list, just doing an insertion as appropriate each time.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote