I'm trying to build a simple deficit round robin scheduler, and right now I'm trying to get the function that has had the least time running. I'm getting a "Bus Error" returned to me when I try to convert an iterator to a pointer. Below is my code, ptof is simply a typedef pointer to the kind of functions I have in my deque and State has the info for each process. What am I doing wrong? Your help would be greatly appreciated.
ptof leastTime(deque<ptof> fnc, map<ptof, State *> s){
double leastElapsed= 100000000;
ptof f;
deque<ptof>::iterator it;
for (it=fnc.begin() ; it < fnc.end(); it++ ){
if(s[*it]->elapsed<leastElapsed){
f = (ptof)(&(*it));
cout<< s[f]->name<<endl;
}
}
return f;
}