anyone here implemented common CS data structures... (stack, queue...)
Rob Cozens
rcozens at pon.net
Thu Jul 8 10:28:02 EDT 2004
>did anyone here, by chance, implemented common data strucutres like
>stacks and queues, like stacks with first in last out behaviour and
>first in first out behaviour...
Hi Andre,
I have used LIFO queues in HyperTalk and Transcript.
The queues are simply global or declared local variables containing
lists of transaction requests. Various handlers check the last line
of the queue and do different things depending on transaction type.
Example: OenoLog has a Wine Lot screen where one can add, edit, &
delete wine lots. The screen includes a "Thumbs Up" button the user
clicks to complete a transaction. When the user initiates a
transaction, "Add", "Edit", or "Delete" is append to the queue in a
new trailing line. On mouseUp the "Thumbs Up" handler checks the
last line of the queue to determine how to process the data in the
window.
It can get more complicated: Suppose I'm in the middle of a Wine Lot
Edit transaction, and when I'm shown the Grape Variety screen to
select the correct variety, it isn't listed. I can interrupt the
Wine Lot Edit transaction and initiate a Grape Variety Add
transaction. The queue now lists "Edit" on one line and "Add" on the
following line. The "Thumbs Up" button on the Grape Variety screen
will process the Add and delete the last line of the queue before
returning the new Grape Variety to the Wine Lot screen and continuing
the Edit.
And it can get even more complicated: Suppose I'm processing a
Winemaking transaction, and when I get to the source tank selection
stage I find the tank hasn't been identified to the system. I must
interrupt the Winemaking Add transaction and initiated a Tank Add
transaction. The Tank Add transaction must be interrupted by a Wine
Lot Add transaction if the Wine Lot in the tank has not been
identified to the system. In turn, that transaction can be
interrupted to initiate Grape Variety Add and Vineyard Add
transactions is those items are missing.
The use of queue-supported, interruptible transactions allows, among
other things, the user to immediately begin transaction processing
with NO initial setup, if desired.
Anything more you'ld like to know.
--
Rob Cozens
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list