Solved

Finding the first (front element in a queue)

Posted on 2004-08-01
3
214 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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 …
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

776 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