PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • WLanguage properties that can be used with the Queue type
  • WLanguage functions for managing the queues
  • The queues and the multithread
  • Browsing the queues
  • Special cases
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
A Queue variable is a structured type that groups a set of elements of the same type. The elements are added at the end of queue and they are retrieved in enqueue order.
For example, if the elements are added in the following order: 1, 2, 3, they will be retrieved in the same order 1, 2, 3.
Example
MyQueue is Queue of int
 
// Enqueue the values 1, 2 and 3
Enqueue(MyQueue, 1)
Enqueue(MyQueue, 2)
Enqueue(MyQueue, 3)
 
// Display the trace: 1, 2, 3
x is int
WHILE Dequeue(MyQueue, x)
Trace(x)
END
Syntax

Declaring and initializing a queue Hide the details

<Queue Name> is Queue of <Type of Queue Elements>
<Queue Name>:
Name of the queue variable to declare.
<Type of Queue Elements>:
Type of elements found in the queue.
All types of variables can be used including the arrays, the associative arrays, the queues, the stacks and the lists. For example:
<variable> is queue of arrays of int

<variable> is queue of fixed arrays of 5 int

<variable> is queue of associative arrays of int

<variable> is queue of queues of int

<variable> is queue of stacks of int

<variable> is queue of lists of int
Remarks

WLanguage properties that can be used with the Queue type

The following properties can be used to handle a Queue variable:
Property nameEffect
AdditionCompletedReturns and modifies the addition mode of elements.
This property is used for the multithread management.
Empty
  • True if the queue is empty,
  • False otherwise.
NbPendingThreadReturns the number of pending threads.
This property is used for the multithread management.
OccurrenceReturns the number of queue occurrences.

WLanguage functions for managing the queues

The following functions can be used to handle a Queue variable:
DequeueRemoves an element from the queue.
DeserializeDeserializes a buffer or a character string containing the data of a class, structure, array (including an associative array), queue, stack, list or advanced variable as well as their sub-elements.
EnqueueAdds an element to the queue.
QueueInfoRetrieves the characteristics of a queue: types of elements and number of elements.
SerializeTransforms the following elements into a specific format:
  • a structure (and its sub-elements),
  • a class (and its sub-elements),
  • an array (including the associative arrays),
  • a queue,
  • a stack,
  • a list.
DeleteAllDeletes all the 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.

The queues and the multithread

The management of multithread is taken into account when adding and deleting an element (Enqueue and Dequeue).
You also have the ability to use properties during a multithread management but the result is not permanent. For example:
IF MyQueue.Occurrence > 0 THEN
// The queue may be empty when the thread reaches this point
 
END

Browsing the queues

The FOR EACH syntax can be used to browse the queues. The elements are browsed in enqueue order that is similar to the dequeue order.
The syntax used corresponds to the one used for the arrays:
FOR EACH [ELEMENT] <Variable> [, <Counter> [, <Counter>]] OF <Queue>
...
END

The elements can be modified during the browse. If the queue is modified during a browse, the elements browsed will be the ones found when the browse was initialized:
  • the elements enqueued after the initialization of the browse will not be browsed.
  • the elements dequeued after the initialization of the browse will still be browsed.

Special cases

  • In the debugger, the content of the queue is displayed in dequeue order.
  • A queue can be used to type a procedure parameter.
  • A queue can be copied with the = operator. You also have the ability to copy an instance of class or structure containing a queue.
  • A queue can be initialized by a list of elements in enqueue order.
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment