# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/linked-lists-in-verse
# Local doc: epic-docs/documentation/en-us/fortnite/linked-lists-in-verse.md
# Section: linked\_list
# A data structure that links multiple list_node structures together to create a chain.
# Uses singly linked nodes which contain a reference to the next node in the chain.
linked_list := class:
# The first node in the list.
var Head:list_node
# Traverses the linked list forward starting from the CurrentNode.
TraverseList():void=
var CurrentNode:?list_node := option{Head} # The node you're currently on
var NodeNumber:int = 1 # The number of the current node.
Print("Starting at the Head Node...")
# If the current node has a next node, set the current node to
# the next node in the list.
loop:
if(NextNode := CurrentNode?.Next?):
set CurrentNode = option{NextNode}
set NodeNumber += 1
Print("Traveling to Node {NodeNumber}!")
else:
Print("No next node, this is the Tail node!")
break
# A data structure that links multiple list_node structures together to create a chain.
# Uses doubly linked nodes which contain references to both the next and previous nodes.
doubly_linked_list := class():
var Head:doubly_linked_node
# Traverse a LinkedList, but both backward and forward!
TraverseDoublyLinkedList():void=
var CurrentNode:?doubly_linked_node := option{Head}
Verse Library
verse
20 Linked List
Implements singly and doubly linked list classes with methods to traverse nodes sequentially and print progress.
extracted-snippets/documentation/en-us/fortnite/linked-lists-in-verse/20-linked-list.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.