cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Priority Queue
Priority Queue
Nov 29, 2010 at 6:45pm
Nov 29, 2010 at 6:45pm UTC
Gajewa469
(10)
I'm having some trouble with priority queues.
I am trying to store a name and time-stamp into a priority queue.
For example:
(Bob, timestamp), (Carol, timestamp), (Cindy, timestamp)
Should I use a class to store both the name and time, and then push that into the queue?
I am eventually going to pop out the names by earliest and latest time, but I am more worried about actually getting them into the queue right now.
Thank you.
Nov 29, 2010 at 7:02pm
Nov 29, 2010 at 7:02pm UTC
Computergeek01
(5613)
I'd say yes, use a struct\class of some type and push that into the queue. This will help you sort them at least as you only have to evaluate one element of the set at a time then you can move the entire object in one operation.
Topic archived. No new replies allowed.