|
|
|
|
|
- WLanguage properties that can be used with the Stack type
- WLanguage functions for managing stacks
- The stacks and the multithread
- Browsing the stacks
- Special cases
Stack (Variable type) In french: Pile
A Stack variable is a structured type that is used to group a set of elements of the same type. The elements are added at the end of stack and they are retrieved from the most recent one. For example, if the elements are added in the following order: 1, 2, 3, they will be retrieved in the following order: 3, 2, 1.
New in version 2025MyStack is Stack of int
Push(MyStack, 1)
Push(MyStack, 2)
Push(MyStack, 3)
x is int
WHILE Pop(MyStack, x)
Trace(x)
END
Syntax
Declaring and initializing a stack Hide the details
<Stack name> is Stack of <Type of stack elements>
<Stack name>: Name of Stack variable to declare. <Type of stack elements>: Type of the elements found in the stack. All types of variables can be used including the arrays, the associative arrays, the queues, the stacks and the lists. For example: <variable> is stack of arrays of int
<variable> is stack of fixed arrays of 5 int
<variable> is stack of associative arrays of int
<variable> is stack of queues of int
<variable> is stack of stacks of int
<variable> is stack of lists of int Remarks WLanguage properties that can be used with the Stack type The following properties can be used to handle Stack variables. | | Property name | Effect |
---|
AdditionCompleted | Returns and modifies the addition mode of elements. This property is used for the multithread management. | Empty | - True if the stack is empty,
- False otherwise.
| NbPendingThread | Returns the number of pending threads. This property is used for the multithread management. | Occurrence | Returns the number of stack occurrences. |
WLanguage functions for managing stacks The following functions can be used to handle Stack variables.
| | DeleteAll | Deletes all elements: - from a one-dimensional or two-dimensional WLanguage array.
- from an associative array.
- from an advanced array property (array of gglCalendar events, etc.).
- from a WLanguage queue.
- from a WLanguage stack.
- from a WLanguage list.
| Deserialize | Deserializes a buffer or a character string containing the data from a class, structure, array (including an associative array), queue, stack, list or advanced variable, as well as their subelements. | Pop | Pops an element from a stack. | Push | Pushes an element onto the stack. | Serialize | Transforms the following elements into a specific format:- a structure (and its subelements),
- a class (and its subelements),
- an array (including the associative arrays),
- a queue,
- a stack,
- a list.
| StackInfo | Retrieves the characteristics of a stack: types of elements and number of elements. |
The stacks and the multithread The management of multithread is taken into account when adding and deleting an element ( Push and Pop). You also have the ability to use properties during a multithread management but the result is not permanent. For example: IF MyStack.Occurrence > 0 THEN
END
Browsing the stacks The FOR EACH syntax can be used to browse the stacks. The elements are browsed in pop order that is the reverse order of the push order. The syntax used corresponds to the one used for the arrays: FOR EACH [ELEMENT] <Variable> [, <Counter> [, <Counter>]] OF <Stack> ... END The elements can be modified during the browse. If the stack is modified during a browse, the elements browsed will be the ones found when the browse was initialized: - the elements pushed after the initialization of the browse will not be browsed.
- the elements popped after the initialization of the browse will still be browsed.
Special cases - In the debugger, the content of the stack is displayed in pop order.
- A stack can be used to type a procedure parameter.
- A stack can be copied by the operator '='. You also have the ability to copy a class or structure instance containing a stack.
- A stack can be initialized by a list of elements in push order.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|