Verse Library verse

09 Enqueue And Dequeue

Adds elements to the back and removes them from the front of a queue structure.

extracted-snippets/documentation/en-us/fortnite/stacks-and-queues-in-verse/09-enqueue-and-dequeue.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/stacks-and-queues-in-verse
# Local doc:  epic-docs/documentation/en-us/fortnite/stacks-and-queues-in-verse.md
# Section:    Enqueue and Dequeue
# Adds a new element to the back of the queue by returning a
# new queue with NewElement at the back.
Enqueue<public>(NewElement:t):queue(t)=
queue(t){Elements := Elements + array{NewElement}}
# Removes the element at the front of the queue and returns a tuple of
# both a new queue with the element removed and the removed element.
Dequeue<public>()<decides><transacts>:tuple(queue(t),t)=
FirstElement := Front[]
(queue(t){Elements := Elements.RemoveElement[0]}, FirstElement)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in