Skip to content

Foreach

Sancky edited this page Sep 26, 2022 · 1 revision

Description

Loop through a queue.

Example

new Queue:queue<10>;

Queue_InsertValue(queue, 2);
Queue_InsertValue(queue, 5);
Queue_InsertValue(queue, 10);
Queue_InsertValue(queue, 15);
Queue_InsertValue(queue, 20);
Queue_InsertValue(queue, 25);

Queue_Foreach(new i : queue) 
{
    printf("Element %d", i);
}

// using extended version
Queue_ForeachEx(new i, idx : queue)
{
    printf("Element %d - index %d", i, idx);
}

Remarks

  • i is the variable in which is assigned the element.
  • idx for the extended version is the variable in which is assigned the element index.

Clone this wiki locally