Solved

Finding the first (front element in a queue)

Posted on 2004-08-01
3
213 Views
Last Modified: 2010-04-01
How would I find the front (first) element in a queue.  Thanks for your help :)
0
Comment
Question by:justinmaurer
3 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11690364
Do you have some code to work on?
You can have a pointer to the first element, and even you can traverse queue backward if you double-link each element in queue.
0
 

Author Comment

by:justinmaurer
ID: 11690383
not really, I'm just doing a simulation, in which I have a car that is supposed to find the shortest line...once it finds the shortest line ...it waits in the line until it the car's turn comes up.  When the car is next in line it has data that is collected from the car.

I hope that isn't too vague

Justin
0
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 11690385
#include <deque>
using namespace std;

//...

deque<MYTYPE> dqMt;

MYTYPE& rmt = dqMt.front();

won't help, I guess... If *you* are implementing a custom DQ, check for the pbject with a NULL pointer to the 'previous' element.
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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now