Solved

Event simulation using priority queues

Posted on 2006-11-01
4
235 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
  • 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 500 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

820 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