Solved

Event simulation using priority queues

Posted on 2006-11-01
4
233 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 134
Prototype for MessageDlg in Embacadero XE 2 2 35
How to convert MFC APP to Win32 APP. 19 71
show out valin of json for debugging in visaul c++ 1 18
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now