Skip to content

Class Stack

Kristian Virtanen edited this page Oct 19, 2024 · 4 revisions

Description:

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.

Properties

Stack.LastError

  • 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."

Methods

Stack.PushValue(stackName, value)

  • 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.

Stack.GetCount(stackName)

  • 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.

Stack.PopValue(stackName)

  • 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.

Stack.Remove(stackName)

  • 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.

Top

Clone this wiki locally