• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Finding the first (front element in a queue)

How would I find the front (first) element in a queue.  Thanks for your help :)
0
justinmaurer
Asked:
justinmaurer
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
justinmaurerAuthor Commented:
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
 
jkrCommented:
#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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now