- Joined
- Apr 24, 2012
- Messages
- 5,113
I coded this useless crapcake because i can't think of anything to code.
And also,my JASSHelper is drunk
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: