VerseIsland
Feed Learn Leaderboard Guides Reference Explore Search Docs Verse Library
Sign in
Feed Learn 📖 Codex Leaderboard Guides Reference Explore Search Docs Verse Library
Verse Library › Devices
Browse Verse Library

Library

Devices 634
  • Devices171
  • Triggers & Logic118
  • UI & HUD40
  • Audio39
  • Items & Inventory29
  • Events27
  • Scoring & Objectives25
  • Spawning19
  • Classes & Interfaces18
  • Game Modes17
  • Props & Meshes14
  • Variables & Mutability12
  • Player Management11
  • Modules & Structure10
  • Round Flow8
  • Animation6
  • Concurrency6
  • Functions6
  • Getting Started6
  • Teams & Classes6
  • NPCs & AI5
  • Tutorials5
  • VFX & Particles5
  • Arrays & Maps4
  • Cameras4
  • Debugging4
  • Control Flow3
  • Cinematics2
  • Other2
  • Persistence2
  • Scene Graph2
  • Structs & Enums2
  • Building1
  • Physics1
  • Publishing & Islands1
  • Syntax & Types1
  • Vehicles1
  • Weapons1
Verse Language 257
  • Control Flow35
  • Functions26
  • Arrays & Maps25
  • Classes & Interfaces22
  • Variables & Mutability22
  • Concurrency21
  • Syntax & Types18
  • Modules & Structure12
  • Debugging8
  • Devices8
  • Events7
  • Player Management6
  • Structs & Enums6
  • Triggers & Logic6
  • Game Modes5
  • Failure & Options4
  • Scene Graph4
  • UI & HUD4
  • Getting Started3
  • Round Flow3
  • Spawning3
  • VFX & Particles3
  • Reference2
  • Animation1
  • Best Practices1
  • Other1
  • Props & Meshes1
Materials/VFX 154
  • Triggers & Logic27
  • UI & HUD17
  • Devices16
  • VFX & Particles14
  • Props & Meshes11
  • Scoring & Objectives9
  • Game Modes7
  • Items & Inventory7
  • Functions6
  • Arrays & Maps5
  • Animation3
  • Cinematics3
  • Classes & Interfaces3
  • Control Flow3
  • Events3
  • Modules & Structure3
  • Round Flow3
  • Spawning3
  • Getting Started2
  • Scene Graph2
  • Variables & Mutability2
  • Concurrency1
  • Persistence1
  • Player Management1
  • Structs & Enums1
  • Syntax & Types1
General 153
  • Devices22
  • Events20
  • Triggers & Logic20
  • Classes & Interfaces10
  • Variables & Mutability8
  • Round Flow6
  • Scoring & Objectives6
  • UI & HUD6
  • Functions5
  • Player Management5
  • Game Modes4
  • Getting Started4
  • Props & Meshes4
  • Control Flow3
  • Syntax & Types3
  • VFX & Particles3
  • Arrays & Maps2
  • Best Practices2
  • NPCs & AI2
  • Other2
  • Physics2
  • Scene Graph2
  • Spawning2
  • Structs & Enums2
  • Tutorials2
  • Building1
  • Cameras1
  • Cinematics1
  • Failure & Options1
  • Items & Inventory1
  • Teams & Classes1
Player 133
  • Player Management22
  • Teams & Classes19
  • Classes & Interfaces12
  • Devices11
  • Events9
  • Persistence7
  • Triggers & Logic7
  • Arrays & Maps6
  • Functions4
  • Game Modes4
  • Items & Inventory4
  • Round Flow4
  • Debugging3
  • Getting Started3
  • Modules & Structure3
  • Concurrency2
  • Control Flow2
  • Scoring & Objectives2
  • Spawning2
  • Structs & Enums2
  • Physics1
  • Props & Meshes1
  • UI & HUD1
  • Variables & Mutability1
  • Weapons1
Building & Props 131
  • Variables & Mutability15
  • Props & Meshes14
  • Triggers & Logic12
  • Classes & Interfaces10
  • Devices10
  • UI & HUD10
  • Events7
  • Teams & Classes7
  • Animation5
  • Building5
  • Functions5
  • VFX & Particles5
  • Structs & Enums4
  • Control Flow3
  • Game Modes3
  • Items & Inventory3
  • Round Flow3
  • Scene Graph3
  • Arrays & Maps2
  • Concurrency2
  • Reference2
  • Modules & Structure1
NPCs & AI 76
  • NPCs & AI35
  • Spawning7
  • Animation5
  • Variables & Mutability5
  • Classes & Interfaces3
  • Debugging3
  • UI & HUD3
  • Audio2
  • Concurrency2
  • Game Modes2
  • Props & Meshes2
  • Triggers & Logic2
  • Devices1
  • Functions1
  • Getting Started1
  • Reference1
  • VFX & Particles1
Spawning 73
  • Spawning31
  • Events7
  • Concurrency6
  • Player Management6
  • Vehicles5
  • Props & Meshes4
  • Devices3
  • Scene Graph3
  • Items & Inventory2
  • Teams & Classes2
  • Control Flow1
  • Publishing & Islands1
  • Reference1
  • Scoring & Objectives1
Cinematics 71
  • Cameras19
  • Cinematics15
  • Devices11
  • Audio5
  • Animation4
  • Triggers & Logic4
  • Functions2
  • Game Modes2
  • UI & HUD2
  • Classes & Interfaces1
  • Concurrency1
  • Control Flow1
  • Items & Inventory1
  • Modules & Structure1
  • Scene Graph1
  • Templates1
UI 57
  • UI & HUD35
  • Devices5
  • Scoring & Objectives4
  • Classes & Interfaces3
  • Round Flow2
  • Scene Graph2
  • Arrays & Maps1
  • Props & Meshes1
  • Structs & Enums1
  • Templates1
  • Triggers & Logic1
  • Variables & Mutability1
Scene Graph 40
  • Scene Graph9
  • Items & Inventory8
  • Classes & Interfaces3
  • Events3
  • Props & Meshes3
  • Functions2
  • Arrays & Maps1
  • Building1
  • Control Flow1
  • Debugging1
  • Modules & Structure1
  • Player Management1
  • Reference1
  • Structs & Enums1
  • Syntax & Types1
  • Triggers & Logic1
  • UI & HUD1
  • VFX & Particles1
Vehicles 38
  • Spawning11
  • Devices7
  • Vehicles7
  • Props & Meshes4
  • Functions2
  • Game Modes2
  • Failure & Options1
  • Items & Inventory1
  • Reference1
  • Teams & Classes1
  • Tutorials1
Tutorials 37
  • Game Modes6
  • Triggers & Logic5
  • Classes & Interfaces4
  • Events4
  • Props & Meshes3
  • Building2
  • Devices2
  • Items & Inventory2
  • Scoring & Objectives2
  • Animation1
  • Arrays & Maps1
  • Cameras1
  • Concurrency1
  • Physics1
  • Player Management1
  • Structs & Enums1
Weapons 30
  • Game Modes6
  • Weapons6
  • Devices5
  • Items & Inventory3
  • Scoring & Objectives3
  • Spawning2
  • Teams & Classes2
  • Best Practices1
  • Functions1
  • Triggers & Logic1
Items 28
  • Items & Inventory23
  • Devices2
  • Triggers & Logic2
  • Spawning1
Assets 20
  • Modules & Structure6
  • Arrays & Maps3
  • Functions3
  • Scene Graph2
  • Best Practices1
  • Devices1
  • Events1
  • Failure & Options1
  • Physics1
  • Variables & Mutability1
Animation 19
  • Animation10
  • Variables & Mutability4
  • Devices1
  • Player Management1
  • Props & Meshes1
  • Scene Graph1
  • Syntax & Types1
Release Notes 17
  • Classes & Interfaces5
  • Modules & Structure3
  • Concurrency2
  • Control Flow2
  • Variables & Mutability2
  • Debugging1
  • Devices1
  • Items & Inventory1
Input & Controls 16
  • Functions4
  • UI & HUD3
  • Control Flow2
  • Animation1
  • Arrays & Maps1
  • Cinematics1
  • Debugging1
  • Devices1
  • Events1
  • Items & Inventory1
Publishing 8
  • Control Flow5
  • Arrays & Maps1
  • Devices1
  • Syntax & Types1
Audio 7
  • Audio5
  • UI & HUD2
Landscape 7
  • Other4
  • VFX & Particles2
  • Scene Graph1
Persistence 6
  • Structs & Enums2
  • Items & Inventory1
  • Persistence1
  • Publishing & Islands1
  • Variables & Mutability1
Physics 5
  • Functions2
  • Classes & Interfaces1
  • Devices1
  • Syntax & Types1
Creator Economy 3
  • Publishing & Islands2
  • Modules & Structure1
Discovery 3
  • Devices1
  • NPCs & AI1
  • Structs & Enums1
Editor & Project 3
  • Other1
  • Props & Meshes1
  • Tutorials1

Generic List

Module — 2 files
These files compile together (same module folder).
file_1.verse
# With UEFN version 41.00, we can now implement parametric classes with variable members.
 
# The code below provides a parametric list implementation.
 
# As we know, in Verse, adding or removing elements from an array triggers the allocation of a 
# new modified array. When the number of elements is small, the overhead may be acceptable. 
# For larger arrays, however, it can become significant for such a seemingly trivial operation.
 
# Lists provide fast O(1) insertion and removal while avoiding large allocations, typically 
# requiring memory only for a single element. Their ideal use case is scenarios where the 
# contents of the collection are not important in a way that would require iteration, but 
# where efficient acquisition and removal are essential (e.g., object pooling).


ADT<public> := module:

    readable<public>(value_type: type) := interface<computes>:

        GetValue<public>()<reads> : value_type

    modifiable<public>(value_type: type) := interface<computes>:

        SetValue<public>(
            Value: value_type
        )<transacts> : void

    have_next<public>(value_type: type) := interface<computes>:

        TryGetNext<public>()<transacts><decides> : void

    const_iterator<public>(value_type: type) := interface<computes>(
        readable(value_type),
        have_next(value_type)
    ):

    iterator<public>(value_type: type) := interface<computes>(
        const_iterator(value_type),
        modifiable(value_type)
    ):

    List<public> := module:

        # WARNING. Iterators have no concept of ownership. The user must ensure that
        # operations that involve iterators (e.g., Insert, Remove) 
        # are called with iterators originated from the list on which the operation is being 
        # performed.
        parametric_list<public>(value_type: type) := class<allocates>:

            var MaybeFirst<private> : ?node(value_type) = false
            var MaybeLast<private> : ?node(value_type) = false
            var<private> Size<public> : int = 0

            TryGetFirst<public>()<reads><decides> : value_type =
                return MaybeFirst?.Value

            TryGetLast<public>()<reads><decides> : value_type =
                return MaybeLast?.Value

            # Inserts the element before iterator. No iterators should be invalidated.
            # Accepts a HaveNext policy, which will be forwarded to the returned iterator.
            # This allows the caller to control whether the returned iterator is forward or 
            # reverse.
            # Returns an iterator to the inserted element.
            Insert<public>(
                Value: value_type,
                Iterator: const_list_iterator(value_type),
                ?HaveNext: list_have_next(value_type) = list_forward_have_next(value_type){}
            )<transacts> : list_iterator(value_type) =
                if:
                    not Iterator.CurrentNode.MaybePrevious?
                then:
                    return PushFront(Value, ?HaveNext := HaveNext)
                PreviousNode := 
                    Iterator.CurrentNode.MaybePrevious? or 
                        Err("List -> Insert Element: Expected list node")
                Node := node(value_type). Value := Value
                set PreviousNode.MaybeNext = option. Node
                set Iterator.CurrentNode.MaybePrevious = option. Node
                set Node.MaybePrevious = option. PreviousNode
                set Node.MaybeNext = option. Iterator.CurrentNode
                set Size += 1
                return MakeIteratorToNode(Node, HaveNext)

            # Removes the element at iterator. 
            # Iterators to the removed element will be invalidated.
            Remove<public>(
                Iterator: const_list_iterator(value_type)
            )<transacts> : void =
                if:
                    not Iterator.CurrentNode.MaybePrevious?
                then:
                    TryPopFront[] or Err("List -> Remove: Expected Pop Front to succeed")
                    return
                if:
                    not Iterator.CurrentNode.MaybeNext?
                then:
                    TryPopBack[] or Err("List -> Remove: Expected Pop Back to succeed")
                    return
                PreviousNode :=
                    Iterator.CurrentNode.MaybePrevious? or 
                        Err("List -> Remove: Expected list node")
                NextNode :=
                    Iterator.CurrentNode.MaybeNext? or
                        Err("List -> Remove: Expected list node")
                set PreviousNode.MaybeNext = option. NextNode
                set NextNode.MaybePrevious = option. PreviousNode
                set Iterator.CurrentNode.MaybePrevious = false
                set Iterator.CurrentNode.MaybeNext = false
                set Size -= 1

            # Adds an element to the end of the list. No iterators should be invalidated.
            # Returns an iterator to the inserted element.
            PushBack<public>(
                Value: value_type,
                ?HaveNext: list_have_next(value_type) = list_forward_have_next(value_type){}
            )<transacts> : list_iterator(value_type) =
                if:
                    Size = 0
                then:
                    return AllocateFirstElement(Value, HaveNext)
                Node := node(value_type). Value := Value
                Iterator := MakeIteratorToNode(Node, HaveNext)
                Last := MaybeLast? or Err("List -> Push Back: Expected list node")
                set Node.MaybePrevious = MaybeLast
                set Last.MaybeNext = option. Node
                set MaybeLast = option. Node
                set Size += 1
                return Iterator

            # Adds an element to the front of the list. No iterators should be invalidated.
            # Returns an iterator to the inserted element.
            PushFront<public>(
                Value: value_type,
                ?HaveNext: list_have_next(value_type) = list_forward_have_next(value_type){}
            )<transacts> : list_iterator(value_type) =
                if:
                    Size = 0
                then:
                    return AllocateFirstElement(Value, HaveNext)
                First := MaybeFirst? or Err("List -> Push Front: Expected list node")
                Node := node(value_type). Value := Value
                Iterator := MakeIteratorToNode(Node, HaveNext)
                set Node.MaybeNext = MaybeFirst
                set First.MaybePrevious = option. Node
                set MaybeFirst = option. Node
                set Size += 1
                return Iterator

            # Removes the last element of the list and returns its value. 
            # Iterators to the removed element will be invalidated.
            TryPopBack<public>()<transacts><decides> : value_type =
                Last := MaybeLast?
                if. set Last.MaybePrevious?.MaybeNext = false
                set MaybeLast = Last.MaybePrevious
                set Last.MaybePrevious = false
                set Size -= 1
                if:
                    Size = 0
                    set MaybeFirst = false
                return Last.Value

            # Removes the first element of the list and returns its value. 
            # Iterators to the removed element will be invalidated.
            TryPopFront<public>()<transacts><decides> : value_type =
                First := MaybeFirst?
                if. set First.MaybeNext?.MaybePrevious = false
                set MaybeFirst = First.MaybeNext
                set First.MaybeNext = false
                set Size -= 1
                if:
                    Size = 0
                    set MaybeLast = false
                return First.Value

            Clear<public>()<transacts> : void =
                set MaybeFirst = false
                set MaybeLast = false
                set Size = 0

            # Returns a forward iterator to the first element of the list.
            # Forward iterators allow traversal of the list from front to back.
            # For instance, if the list is [A,B,C], a forward iterator would return A, 
            # then B, then C.
            TryBegin<public>()<reads><allocates><decides> : list_iterator(value_type) =
                return MakeIteratorToNode(MaybeFirst?, list_forward_have_next(value_type){})

            # Returns a reverse iterator to the last element of the list.
            # Reverse iterators allow traversal of the list from back to front.
            # For instance, if the list is [A,B,C], a reverse iterator would return C,
            # then B, then A.
            TryEndReversed<public>(
            )<reads><allocates><decides> : list_iterator(value_type) =
                return MakeIteratorToNode(MaybeLast?, list_reverse_have_next(value_type){})

            # Allocates an array and copies the elements of the list into it.
            # The ordering of the elements in the array matches the ordering of the elements in 
            # the list (i.e., the first element of the list is copied to index 0 of the array, 
            # and so on).
            TryMakeArray<public>()<transacts><decides> : []value_type =
                Iterator: const_list_iterator(value_type) = TryBegin[]
                EndIndex := Size - 1
                return:
                    for:
                        Index := 0..EndIndex
                    do:
                        Value := Iterator.GetValue()
                        if:
                            Index < EndIndex
                            Iterator.TryGetNext[] or 
                                Err("List -> Make Array: Expected next element")
                        Value

            MakeIteratorToNode<private>(
                Node: node(value_type),
                HaveNext: list_have_next(value_type)
            )<allocates> : list_iterator(value_type) =
                return:
                    list_iterator(value_type):
                        HaveNext := HaveNext
                        CurrentNode := Node

            AllocateFirstElement<private>(
                Value: value_type,
                HaveNext: list_have_next(value_type)
            )<transacts> : list_iterator(value_type) =
                Size = 0 or Err("List -> Allocate First Element: Expected empty list")
                Node := node(value_type). Value := Value
                set MaybeFirst = option. Node
                set MaybeLast = MaybeFirst
                set Size = 1
                return MakeIteratorToNode(Node, HaveNext)

        const_list_iterator<public>(value_type: type) := class<internal><allocates>(
            const_iterator(value_type)
        ):

            HaveNext<internal> : list_have_next(value_type)

            var CurrentNode<internal> : node(value_type)

            GetValue<override>()<reads> : value_type =
                return CurrentNode.Value

            TryGetNext<override>()<transacts><decides> : void =
                NextNode := HaveNext.TryGetNext[CurrentNode]
                set CurrentNode = NextNode

        list_iterator<public>(value_type: type) := class<internal><allocates>(
            const_list_iterator(value_type),
            modifiable(value_type)
        ):

            SetValue<override>(
                Value: value_type
            )<transacts> : void =
                set CurrentNode.Value = Value

        list_have_next<public>(value_type: type) := interface<computes>:

            TryGetNext<public>(
                CurrentNode: node(value_type)
            )<reads><decides> : node(value_type)

        list_forward_have_next<public>(value_type: type) := class<computes>(
            list_have_next(value_type)
        ):

            TryGetNext<override>(
                CurrentNode: node(value_type)
            )<reads><decides> : node(value_type) =
                return CurrentNode.MaybeNext?

        list_reverse_have_next<public>(value_type: type) := class<computes>(
            list_have_next(value_type)
        ):

            TryGetNext<override>(
                CurrentNode: node(value_type)
            )<reads><decides> : node(value_type) =
                return CurrentNode.MaybePrevious?

        node<internal>(value_type: type) := class<allocates>:

            var MaybePrevious<internal> : ?node(value_type) = false
            var MaybeNext<internal> : ?node(value_type) = false
            var Value<internal> : value_type

        # Removes all elements matching the value. Iterators may be invalidated.
        # We still cannot have the parametric type defined by an implict type parameter 
        # (i.e., parameters defined with the 'where' keyword). 
        # 
        # RemoveAll<public>(
        #   Value: value_type, 
        #   List: parametric_list(value_type) where value_type: subtype(comparable)
        # )<transacts> : void 
        #
        # Using explict ValueType parameter for now.
        RemoveAll<public>(
            ValueType: subtype(comparable),
            Value: ValueType,
            (local:)List: parametric_list(ValueType)
        )<transacts> : void =
            MaybeIterator: ?const_list_iterator(ValueType) = option. (local:)List.TryBegin[]
            if:
                not MaybeIterator?
            then:
                return
            Iterator := MaybeIterator? or Err("List -> Remove All: Expected list iterator")
            loop:
                if:
                    Iterator.CurrentNode.Value = Value
                then:
                    MaybeNextNode := Iterator.CurrentNode.MaybeNext
                    (local:)List.Remove(Iterator)
                    if:
                        NextNode := MaybeNextNode?
                    then:
                        set Iterator.CurrentNode = NextNode
                    else:
                        return
                else:
                    HaveNext := logic. Iterator.TryGetNext[]
                    if:
                        not HaveNext?
                    then:   
                        return

        # Removes all elements matching the predicate. Iterators may be invalidated.
        RemoveAll<public>(
            ValueType: type,
            Predicate(:ValueType, :payload_type)<reads><decides> : void,
            (local:)List: parametric_list(ValueType),
            Payload: payload_type where payload_type: type
        )<transacts> : void =
            MaybeIterator: ?const_list_iterator(ValueType) = option. (local:)List.TryBegin[]
            if:
                not MaybeIterator?
            then:
                return
            Iterator := MaybeIterator? or Err("List -> Remove All: Expected list iterator")
            loop:
                if:
                    Predicate[Iterator.CurrentNode.Value, Payload]
                then:
                    MaybeNextNode := Iterator.CurrentNode.MaybeNext
                    (local:)List.Remove(Iterator)
                    if:
                        NextNode := MaybeNextNode?
                    then:
                        set Iterator.CurrentNode = NextNode
                    else:
                        return
                else:
                    HaveNext := logic. Iterator.TryGetNext[]
                    if:
                        not HaveNext?
                    then:   
                        return
file_2.verse
using { ADT.List } 

IntegerList := parametric_list(int){}
IntegerList.PushFront(10)
IntegerList.PushFront(20)
IntegerList.PushBack(30)
# [20, 10, 30]

IntegerList.TryPopFront[] or Err("Expected value to pop")
IntegerList.TryPopBack[] or Err("Expected value to pop")
# [10]

var Iterator: const_list_iterator(int) = IntegerList.PushBack(50)
IntegerList.Insert(40, Iterator)
# [10, 40, 50]

IntegerList.Remove(Iterator)
# [10, 40]

IntegerList.PushBack(10)
IntegerList.PushBack(20)
IntegerList.PushBack(30)
# [10, 40, 10, 20, 30]

set Iterator = 
    IntegerList.TryEndReversed[] or 
        Err("Expected reverse iterator")
loop:
    Print("{Iterator.GetValue()}")
    HaveNext := logic. Iterator.TryGetNext[]
    if:
        not HaveNext?
    then:
        break
# 30
# 20
# 10
# 40
# 10

Array := IntegerList.TryMakeArray[] or Err("Expected array")
Print("Array: " + ToDiagnostic(Array))
# Array: (10, 40, 10, 20, 30)

RemoveAll(int, 10, IntegerList)
# [40, 20, 30]

RemoveAll(int, RemoveDivisibleBy3, IntegerList, Payload := ())
# [40, 20]

RemoveDivisibleBy3<private>(
    Value: int,
    :void
)<computes><decides> : void =
    Mod[Value, 3] = 0
Sign in to download module

Copy-paste each file above is always free.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in
    📄
    Source
    Epic Games Community

    Created by a member of the Epic Games community. Rights remain with the original author, under Epic's community content terms. Terms ↗

    View original Sources & licensing
    Request removal
    Last updated Jun 23, 2026
    Verse module (2 files)
    Compiles · verified Jun 25, 2026

    Download the full module (zip) from the code panel above.

    Keep exploring
    More in Verse Language · 84 of 106
    Prev
    fortnite grid math
    Next
    fortnite real time api beta
    Related topics
    • Speedboosthigh Creative V1 Epic Items
    • Item Modular Enforcer Ar Epic Items
    • Speedboostlow Creative V1 Uncommon Items
    • Item Modular Tactical Assault Rifle Epic Weapons
    • Item Compact Smg Epic Items

    Related

    Open in graph →

    Related topics

    • Speedboosthigh Creative V1 Epic
    • Item Modular Enforcer Ar Epic
    • Speedboostlow Creative V1 Uncommon
    • Item Modular Tactical Assault Rifle Epic
    • Item Compact Smg Epic
    VerseIsland · an archipelago of Verse & UEFN knowledge
    🗺️ Island atlas Learn Guides History About & Press Sources & Licensing Status

    Not affiliated with Epic Games. Fortnite, UEFN, Unreal Engine, and Verse are trademarks of Epic Games, Inc. Content is attributed to its source — see Sources & Licensing.

    🦜

    Scout · your island guide

    The Isle of Verse