Reputation: 339
I have this Queue below which is FIFO.
queue Printers[1];
I have the following information stored on each front in a queue.
int PID;
string Filename;
int Memstart;
char rw;
int Filelength;
int Cylinder;
If I was to add to this queue it would just pop it on every time and wouldnt be ordered.
Is there a hack or a way to rearrange this queue based on the Cylinder?
I want it so that the queue is based in order on the Cylinder.
So for example if I add to the queue
Cylinder 1 3 6 3 in that order, it would come out in the order 1 3 3 6.
Is there a way to rearrange a fifo queue based on a certain variable?
Thanks!
Upvotes: 0
Views: 231
Reputation: 6814
Well a fifo queue is by definition First-In-First-Out, so that's not going to give you what you want, you may want look into something like a Priority Queue (also called Min Heap)
http://en.wikipedia.org/wiki/Heap_(data_structure)
Upvotes: 1