|
-
May 23rd, 2003, 11:47 AM
#16
I did forget one thing. One the m_PendingJobs map becomes empty I have to make sure to empty the m_JobKeys deque
The proper code at the completion of a job is
PHP Code:
if (wParam != m_PendingJobs.size() - 1)
m_JobKeys.push_back(wParam);
m_PendingJobs.erase(m_PendingJobs.find(wParam));
if (m_PendingJobs.empty())
m_JobKeys.clear();
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
December 25th, 2003, 04:45 AM
#17
Re: std::map key values
Originally posted by souldog
I need to generate new unique key values. I could just find the largest key with a reverse iterator and add one. A remote, but conceivable problem is that the key values keep growing until they are too large for int. Since I ecpect elements of the map to be removed at a pretty good rate, I decided to find the first available key value...
1. If you use unsigned int as key and i is the MAX value of unsigned int, then i++ is 0
2. When you remove a job, delete the greatest key and insert its job at the key of deleted job. for new jobs, you could then use greatest key + 1 (but if you use all the keys possible (4, 000, 000, 000 + something I think), you would still have a problem)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|