Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Event simulation using priority queues

Posted on 2006-11-01
4
Medium Priority
?
240 Views
Last Modified: 2010-04-01
Im writing a program which deals with a character going to a wizard cave at a certain time.  In a text file contains the characters' arrival time and request time.  I need to put  the times in a vector then into a priority queue, where the lowest time is the highest priority.  Can I have any help or guidance to start on project.  What type of classes do I need and what do I need to contain in these classes?
0
Comment
Question by:MissProgrammer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17855783
std::priority_queue
0
 

Author Comment

by:MissProgrammer
ID: 17855794
What does that suppose to mean??
0
 
LVL 84

Accepted Solution

by:
ozo earned 1500 total points
ID: 17856364
#include <iostream>
//for example
#include <iostream>
#include <list>
#include <queue>
int main(){
  std::priority_queue<int, std::vector<int>, std::greater<int> > intPQueue;
  intPQueue.push(2);
  intPQueue.push(7);
  intPQueue.push(1);
  intPQueue.push(8);
  std::cout << "values removed from priority queue" << std::endl;
  int size=intPQueue.size();
  for( int i=0; i<size; i++ ){
    std::cout << intPQueue.top() << std::endl;
    intPQueue.pop();
  }
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question