• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Singly Linked List Module

I coded this useless crapcake because i can't think of anything to code.

And also,my JASSHelper is drunk

JASS:
library SinglyLinkedList
    module SinglyLinkedList
        private static thistype array next
        
        /*******************************************
        *
        *              INSERT METHODS
        *
        *******************************************/
        static method insert takes thistype node, thistype newNode returns nothing
            set next[node] = newNode
        endmethod
        
        static method insertAfter takes thistype node, thistype newNode returns nothing
            set next[newNode] = next[node]
            call thistype.insert(node, newNode)
        endmethod
        
        static method insertBeginning takes thistype newNode returns nothing
            set next[newNode] = next[0]
            call thistype.insert(thistype(0), newNode)
        endmethod
        /*******************************************
        *
        *              REMOVE METHODS
        *
        *******************************************/
        static method remove takes thistype node, thistype prevNode returns nothing
            set next[prevNode] = next[node]
        endmethod
        
        static method removeAfter takes thistype node, thistype prevNode returns nothing
            call thistype.remove(node, prevNode)
        endmethod
        
        static method removeBeginning takes thistype node returns nothing
            call thistype.remove(node, thistype(0))
        endmethod

        /*******************************************
        *
        *              ITERATION METHODS
        *
        *******************************************/
        static method operator firstNode takes nothing returns thistype
            return next[0]
        endmethod

        method operator nextNode takes nothing returns thistype
            return next[this]
        endmethod
    endmodule

    /*******************************************
    *
    *           ITERATION MODULES
    *
    *******************************************/
    module SLLIterationStart
        local thistype this = thistype.firstNode
        loop
            exitwhen 0 == this
    endmodule

    module SLLIterationEnd
            set this = this.nextNode
        endloop
    endmodule
endlibrary
 
Last edited:
Top