09-10-2023, 02:47 PM
(This post was last modified: 09-10-2023, 02:49 PM by TerryRitchie.)
(09-10-2023, 01:45 PM)TarotRedhand Wrote: @bplus I doubt using a dynamic array to emulate a true stack will aid with those 2 things, it should be relatively straightforward to implement a faux stack. (a queue and/or a deque on the other hand...). Just need a simple variable to hold the ToS (Top of Stack) and use Redim _Preserve somewhat liberally.Just curious, where would a stack be handy in QB64 programming?
TR
I created a stack like structure in my Super Megabug game way back in 2010 to store locations of maze endpoints as random mazes are created. But I used a stack structure simply because I was new to QB64 and was familiar with their use when I programmed in Assembler. I could have just as easily used an array.
Perhaps a fixed (static) sized _MEM structure could be used and a stack pointer indicating the current memory location much the same as was done in Assembler. Depending on the pointer use you could create a LIFO or FIFO stack. I think using _REDIM _PRESERVE would be rather slow for something like a stack that is constantly updating.