|
|
|
|
|
- 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
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. Novedad versión 2025MyStack is Stack of int // Push the values 1, 2 and 3 Push(MyStack, 1) Push(MyStack, 2) Push(MyStack, 3) // Display the trace: 3, 2, 1 x is int WHILE Pop(MyStack, x) Trace(x) END
Sintaxis
Declaring and initializing a stack Ocultar los detalles
<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 Observaciones WLanguage properties that can be used with the Stack type The following properties can be used to define the characteristics of 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 | Deserializa un búfer o una cadena de caracteres que contiene los datos de una clase, estructura, array (incluyendo un array asociativo), cola, pila, lista o variable avanzada, así como sus subelementos. | Pop | Pop un elemento de un apilamiento. | Push | Pushes an element onto the stack. | Serializar | Transforma los siguientes elementos en un formato específico:- una estructura (y sus subelementos),
- una clase (y sus subelementos),
- un array (incluidos los arrays asociativos),
- una cola,
- un apilamiento,
- una lista.
| StackInfo | Recupera las características de un apilamiento: tipos de elementos y número de elementos. |
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.
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|