Skip to main content
Version: 4.45.0

Stack

The stack component allows to do depth-first traversing (longest branches before the shortest branch of a tree), but it also facilities processing data in a certain order.

Inputs

Children

Any value which should be appended to the end of the stack

Example: A

Finished Parent

Pops the last value in the stack.

Example: Any message

Outputs

Output

Last value in the stack.

Example (reporting)

Folder structure:

A
/ \
B C
/ \
D E

In this example, we would like to output to the log, in the order shown below. The objects have a parent-child relationship. The execution flow will look as follows:

  • Retrieve A (stack: [])

  • Send A to log (stack: [])

  • Get children of A in reversed order and add to stack using Children input (stack: [C, B])

  • Send a message to Finished Parent input of stack, pops B (stack: [C])

  • Send B to log (stack: [C])

  • Get children of B in reversed order and add to stack using Children input (stack: [C, E, D])

  • Send a message to Finished Parent input of stack, pops D (stack: [C, E])

  • Send D to log (stack: [C, E])

  • Get children of D in reversed order and add to stack using Children input (stack: [C, E])

  • Send a message to Finished Parent input of stack, pops E (stack: [C])

  • Send E to log (stack: [C])

  • Get children of E in reversed order and add to stack using Children input (stack: [C])

  • Send a message to Finished Parent input of stack, pops C (stack: [])

  • Send C to log (stack: [])

Note

To have the result in ascending order, you need to sort the input in descending (reversed) order as shown in the example above.