Stack and Queue functions (LIFO and FIFO) #405
Peter-Jacob
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
By leveraging the linked list implementation, we can easily implement stack functionality on top of it. The stack operates as a standard stack, without additional behavior like waiting for input from the keyboard or other input sources. The cherry on top? It supports several parallel stacks—because one just isn’t enough.
I almost overlooked the most obvious approach: encapsulating the functionality in REXX.
For example, to PULL data from the stack, I use the following REXX code:
This eliminates the need to write additional code in the plugin.
These are the functions we have so far:
PUSH(queue-number, data) pushes the data onto the stack's top.
QUEUE(queue-number, data) adds the data to the beginning of the stack.
PULL(queue-number) retrieves and removes the topmost entry from the stack.
QPULL(queue-number) returns the first entry from the stack and removes it. (I never understood why it isn't part of the standard)
Beta Was this translation helpful? Give feedback.
All reactions