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.PeekFirst

Previous Top Next


MiniRobotLanguage (MRL)

 

ARS.PeekFirst

Peek at the first element of the Deque without removing it.

 

 

Intention

 

The ARS.PeekFirst command allows you to view the first element of the Deque without removing it. This is useful for inspecting the element at the front of the Deque without altering its contents.

 

 

Illustration:

 

Deque Structure:

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

│ FirstElement  │  ← Peeked

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

│ SecondElement │

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

│ LastElement   │

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

 

The last element is inspected but remains in the Deque.

 

Syntax

 

ARS.PeekFirst|$$DEQ|$$RES

 

 

Parameter Explanation

 

P1 - $$DEQ The handle of the Deque.

P2 - $$RES The variable to store the first element of the Deque.

 

 

Example

 

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

' ARS.PeekFirst - Sample Script

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

' Create a new Deque

ARS.New|$$DEQ

' Push elements onto the Deque

ARS.PushFirst|$$DEQ|FirstElement

ARS.PushLast|$$DEQ|LastElement

' Peek at the first element

ARS.PeekFirst|$$DEQ|$$RES

DBP.The first 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.PopFirst