Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Shannon Barber

Delphi TQueue, need to push_front

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Wouldnt that be against the idea of a queue?

Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites
Yep, it certainly would... unless you're the kinda person who barges to the front .

Anyway, here's a sample project I knocked up in a second:
TNotAQueue (about 2Kb)

It seems to work, but be sure to test that! I did it by deriving a class from TQueue and adding in another procedure, "Barge". That adds to the front of the queue (which, strangely, means the back of the list? wtf?). Anyway, the important thing to note is the protected member "List". I used that directly, which seems safe...

Lifepower: it's in the unit "contnrs" w/ Delphi 5 or 6 (can't remember which). That's if you're not joking... I can't tell because I'm high on caffeine just now.

Alimonster

There are no stupid questions, but there are a lot of inquisitive idiots.

Edited by - Alimonster on January 30, 2002 11:44:23 AM

Share this post


Link to post
Share on other sites
Also worth noting: if you only need push to front behaviour then use TStack instead of TQueue. If you need both add to front and back behaviour then you could just use a TList instead of that thing above. It''s just a case of adding and inserting to the right places.

Share this post


Link to post
Share on other sites
2 Alimonster: Nope, I wasn''t joking - I didn''t know this class. Actually, even though I''ve been through all versions of Delphi (starting from 1), never used many Delphi built-in classes (like TList, etc) - did all that stuff myself (and I still keep my source code . Have my own reasons for that though....
btw, as I checked out TQueque list, it seems Borland haven''t gone too far with it... (maybe that''s at first sight? )

Share this post


Link to post
Share on other sites
I had a queue of stuff to process, and sometimes it''s necessary to add a step (if things don''t go right) that needs to be processed before the rest of the steps. I''m now using a stack instead, and I just push everything on in reverse order. So far, I haven''t run into a case where I need to add a step to the end... I guess if I do I''ll just write my own (array based) deque.

The TStack/TQueue/TList objects are, shall we say, less than optimal, but I didn''t need speed for this piece of code.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!