• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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