Click here to Skip to main content
15,921,295 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: vista and MFC Pin
suraj Chhetry24-Apr-07 19:47
suraj Chhetry24-Apr-07 19:47 
AnswerRe: vista and MFC Pin
prasad_som24-Apr-07 21:12
prasad_som24-Apr-07 21:12 
GeneralRe: vista and MFC Pin
suraj Chhetry24-Apr-07 21:39
suraj Chhetry24-Apr-07 21:39 
AnswerRe: vista and MFC Pin
prasad_som24-Apr-07 22:23
prasad_som24-Apr-07 22:23 
Questionpriority queue with time limit Pin
charian092024-Apr-07 16:38
charian092024-Apr-07 16:38 
AnswerRe: priority queue with time limit Pin
Arman S.24-Apr-07 20:40
Arman S.24-Apr-07 20:40 
GeneralRe: priority queue with time limit Pin
charian092024-Apr-07 21:18
charian092024-Apr-07 21:18 
GeneralRe: priority queue with time limit Pin
Arman S.25-Apr-07 20:20
Arman S.25-Apr-07 20:20 
StructPriorityRequest should have another field that shows the insertion time; integer value timeStart. Which will be initialized in push like so;

bool push( const T& x )
{
bool rtn = true;
Lock();
if(m_q.size() > m_intMaxSize)
{
rtn = false;
}
else
{
x.timeStart = time(NULL); // HERE
m_q.push( x );
}
Unlock();
return rtn;
}

Then modify the < operator of StructPriorityRequest like so;

bool operator < (const _StructPriorityRequest &structT2) const
{
int myAge = time(NULL) - timeStart;
int herAge = time(NULL) - structT2.timeStart;

return intPriority > structT2.intPriority && /*ALSO CONSIDER myAge and herAge */;
}

IMPORTANT:
As far a know, std::priority_queue does the element comparision inside push method not pop. But the method I've described works if the queue does comarision inside pop not push. So make sure if so, you have to change the container std::priority_queue. Otherwise you will have no way to calculate ages.

--
=====
Arman

GeneralRe: priority queue with time limit Pin
charian092026-Apr-07 17:22
charian092026-Apr-07 17:22 
GeneralRe: priority queue with time limit Pin
Arman S.26-Apr-07 19:45
Arman S.26-Apr-07 19:45 
QuestionFILE* fp and argv[] Pin
C_Zealot24-Apr-07 13:49
C_Zealot24-Apr-07 13:49 
AnswerRe: FILE* fp and argv[] Pin
Michael Dunn24-Apr-07 14:53
sitebuilderMichael Dunn24-Apr-07 14:53 
AnswerRe: FILE* fp and argv[] Pin
Sarath C24-Apr-07 15:18
Sarath C24-Apr-07 15:18 
QuestionDynamic memory allocation and Buffer length Pin
C_Zealot24-Apr-07 13:18
C_Zealot24-Apr-07 13:18 
QuestionRe: Dynamic memory allocation and Buffer length Pin
David Crow24-Apr-07 16:26
David Crow24-Apr-07 16:26 
AnswerRe: Dynamic memory allocation and Buffer length Pin
cmk25-Apr-07 13:25
cmk25-Apr-07 13:25 
QuestionDialog box error - check code [modified] Pin
Dustin Henry24-Apr-07 11:21
Dustin Henry24-Apr-07 11:21 
AnswerRe: Dialog box error - check code Pin
Mark Salsbery24-Apr-07 11:32
Mark Salsbery24-Apr-07 11:32 
GeneralRe: Dialog box error - check code Pin
Dustin Henry24-Apr-07 11:48
Dustin Henry24-Apr-07 11:48 
GeneralRe: Dialog box error - check code Pin
Mark Salsbery24-Apr-07 12:02
Mark Salsbery24-Apr-07 12:02 
GeneralRe: Dialog box error - check code Pin
Dustin Henry24-Apr-07 13:34
Dustin Henry24-Apr-07 13:34 
GeneralRe: Dialog box error - check code Pin
Mark Salsbery24-Apr-07 13:48
Mark Salsbery24-Apr-07 13:48 
QuestionRe: Dialog box error - check code Pin
David Crow24-Apr-07 16:28
David Crow24-Apr-07 16:28 
JokeRe: Dialog box error - check code Pin
Rajesh R Subramanian24-Apr-07 20:20
professionalRajesh R Subramanian24-Apr-07 20:20 
QuestionNovice Programmer here: Linking Pin
Jay Minor24-Apr-07 9:15
Jay Minor24-Apr-07 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.