So, what do you guys think? Are N-Dimensional Arrays Useful?
Something like:
You could set the data to a [ljass]struct extends array[/ljass] that holds your data.
Jesus's Code:
Something like:
JASS:
set MyMultiDimensionalArray[1][2][3][4][5][6][7] = 1328
You could set the data to a [ljass]struct extends array[/ljass] that holds your data.
Jesus's Code:
JASS:
library NArray // Jesus4Lyf's NArray demonstration.
struct NArray
private static hashtable Store=InitHashtable()
private thistype next
private thistype prev
private static thistype new
method operator[] takes integer index returns thistype
if not HaveSavedInteger(Store,this,index) then
set thistype.new=thistype.allocate()
set this.prev.next=thistype.new
set thistype.new.prev=this.prev
set thistype.new.next=this
set this.prev=thistype.new
call SaveInteger(thistype.Store,this,index,thistype.new)
return thistype.new
endif
return thistype(LoadInteger(thistype.Store,this,index))
endmethod
method operator []= takes integer index, integer value returns nothing
call SaveInteger(thistype.Store,this,index,value)
endmethod
static method create takes nothing returns thistype
local thistype this=thistype.allocate()
set this.next=this
set this.prev=this
return this
endmethod
method destroy takes nothing returns nothing
local thistype node=this.next
loop
call FlushChildHashtable(thistype.Store,node)
call node.deallocate()
exitwhen node==this
set node=node.next
endloop
endmethod
endstruct
endlibrary