ARS. - Deque Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Arrays and Data-Structures > ARS. - Array's > !ARS. - Deque Operations >

ARS. - Deque Operations

ARS.PopFirst

Previous Top Next


MiniRobotLanguage (MRL)

 

ARS.PopFirst

Pop the first element from the Deque and return its value.

 

 

Intention

 

The ARS.PopFirst command removes the first element from the Deque and returns its value. This is useful for processing elements in a first-in-first-out (FIFO) manner.

 

 

Illustration:

 

Deque Structure:

┌───────────────┐

│ FirstElement  │ ← Popped

├───────────────┤

│ SecondElement │

├───────────────┤

│ LastElement   │

└───────────────┘

 

The first element is removed and returned.

 

Syntax

 

ARS.PopFirst|$$ARR[|$$VAL]

 

 

Parameter Explanation

 

P1 - $$ARR The handle of the Deque.

P2 - $$VAL (optional) The variable to store the popped element. If omitted, the value is placed on the Top of Stack (TOS).

 

 

Example

 

'***********************************

' ARS.PopFirst - Sample Script

'***********************************

' Create a new Deque

ARS.New|$$DEQ

' Push elements onto the Deque

ARS.PushFirst|$$DEQ|FirstElement

ARS.PushLast|$$DEQ|LastElement

' Pop the first element

ARS.PopFirst|$$DEQ|$$RES

DBP.The popped element is: $$RES

' End the script

ENR.

 

 

Remarks

 

-

 

 

Limitations:

- The Deque must not be empty when using this command.

 

See also:

 

ARS.New

ARS.PushFirst

ARS.PeekFirst