-
Notifications
You must be signed in to change notification settings - Fork 0
Class Stack
Kristian Virtanen edited this page Oct 28, 2024
·
4 revisions
The Stack
class provides methods to create and manage multiple stacks, each identified by a unique name. It allows values to be pushed and popped from stacks, and includes error handling via the LastError
property, which stores the most recent error message if an operation fails.
-
Description: Stores the last error message, if any operation fails, including a timestamp in
yyyy-MM-dd HH:mm:ss
format. -
Example:
"2024-10-16 14:30:00: Stack with name 'myStack' does not exist."
- Changes from orig. SB: New feature for SBOE.
- Description: Pushes a value onto the specified stack. If the stack does not exist, it is created.
-
Parameters:
-
stackName
: The name of the stack to push the value onto. -
value
: The value to push onto the stack.
-
-
Returns:
true
if the value was successfully pushed,false
if an error occurred. -
Changes from orig. SB: SBOE returns
true
orfalse
by succes.
- Description: Returns the number of items in the specified stack.
-
Parameters:
-
stackName
: The name of the stack to get the count of items from.
-
-
Returns: The number of items in the stack, or
-1
if the stack does not exist. - Changes from orig. SB: none.
- Description: Pops the top value from the specified stack.
-
Parameters:
-
stackName
: The name of the stack to pop the value from.
-
-
Returns: The value popped from the top of the stack, or
null
if the stack is empty or does not exist. -
Changes from orig. SB: SBOE returns
true
orfalse
by succes.
- Description: Removes stack with name passed as parameter.
-
Parameters:
-
stackName
: The name of the stack to remove.
-
- Returns: true if stack removed succesfully, false if not.
- Changes from orig. SB: New feature for SBOE.