Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Stacks? Queues? Lists? I'm confused...

Author
Message
Mr Underhill
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location: The Forgotten Worlds...
Posted: 2nd Jul 2003 07:44
OK, I'm an old DBC fan, and I'm used to good ol' arrays . These DBPro stacks, lists, and queues look cool, but..I'm confused on how to use them :-s . I looked in help but I didn't quite get it. Could anyone give me a crash-course on what these new-fangled things are and how to use 'em? Thanks in advance!
-Underhill
"You're drawing too much attention to yourself, 'Mr.Underhill'!" - Aragorn (Strider)
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 2nd Jul 2003 13:33
I've no idea how to use them in DB, but I can give you an idea of what they are about.

Stacks:
A stack can be regarded as a pile of data. You can put data onto the pile, and you can take data off. Now, you can only do this to the top item of data on the pile, so the last piece you put on is the first one you'll grab off.

Queues:
Queues are easier to understand, they are like lines of data. Like stacks you can add data to the line and take data away from the line, but unlike stacks, you can only take data away from the front of the queue, so the first piece of data you put in is the first piece of data you'll get out again.

Those are the concepts, I'm not sure how to use them in DB.

Once I was but the learner,
now, I am the Master.
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 2nd Jul 2003 18:33
When you go, go as Mr. Underhill!

Sorry. Thats completely off-topic. I just felt I had to interpose with some advice from Gandalf.

Phil

Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 2nd Jul 2003 19:03
I think an example of where you can use queues is calculators (just simple ones, on B.O.D.M.A.S. rule). You add the numbers in the sequence onto the queue and the operators into another queue, then when you press equals then the calculator takes the first item off of the numbers queue and then the first operator, then the next number and "operate" them together (sorry for not being technical). Then you carry on until all the numbers are used up, then you have an answer.

I guess you could make your own stack and queue functions if you wanted.

cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Jul 2003 21:25 Edited at: 2nd Jul 2003 21:25
I've got a lot of test code for arrays. I'll extract/expand some of it so that you can see a full example of how stacks/queues/lists work.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2003 00:21
Well, I didn't get around to doing the list stuff tonight - I'll do it for you tomorrow. It's actually easier than stacks or queues.

Here's the queue demo code:


Here's the stack demo code:


There are a few comments near the top, but not in the rest of the code - I'm hoping it'll be self-explanatory

Do note within the PrintQueue and PrintStack functions that you are still able to access the queue/stack as a normal array if you wish.

Login to post a reply

Server time is: 2024-09-20 13:25:37
Your offset time is: 2024-09-20 13:25:37