Discussion N-Dimensional Arrays, Useful?

Sevion

The DIY Ninja
Reaction score
424
So, what do you guys think? Are N-Dimensional Arrays Useful?

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
 

Bribe

vJass errors are legion
Reaction score
67
Hmm, I've got to see how that compiles, maybe I can start using Vex's arrays instead of the hashtables I've been using.
 

Bribe

vJass errors are legion
Reaction score
67
Ouch, I'll stick to hashtables, thanks!

JASS:
globals
// processed:     integer array foo [1000][400]


//JASSHelper struct globals:
integer array s__foo
integer array s__2foo
integer array s__3foo
integer array s__4foo
integer array s__5foo
integer array s__6foo
integer array s__7foo
integer array s__8foo
integer array s__9foo
integer array s__10foo
integer array s__11foo
integer array s__12foo
integer array s__13foo
integer array s__14foo
integer array s__15foo
integer array s__16foo
integer array s__17foo
integer array s__18foo
integer array s__19foo
integer array s__20foo
integer array s__21foo
integer array s__22foo
integer array s__23foo
integer array s__24foo
integer array s__25foo
integer array s__26foo
integer array s__27foo
integer array s__28foo
integer array s__29foo
integer array s__30foo
integer array s__31foo
integer array s__32foo
integer array s__33foo
integer array s__34foo
integer array s__35foo
integer array s__36foo
integer array s__37foo
integer array s__38foo
integer array s__39foo
integer array s__40foo
integer array s__41foo
integer array s__42foo
integer array s__43foo
integer array s__44foo
integer array s__45foo
integer array s__46foo
integer array s__47foo
integer array s__48foo
integer array s__49foo

endglobals


function sg__foo_get takes integer i returns integer
    if(i<8191) then
        return s__foo<i>
    elseif(i&lt;204775) then
        if(i&lt;16382) then
            return s__2foo[i-8191]
        elseif(i&lt;106483) then
            if(i&lt;24573) then
                return s__3foo[i-16382]
            elseif(i&lt;65528) then
                if(i&lt;32764) then
                    return s__4foo[i-24573]
                elseif(i&lt;49146) then
                    if(i&lt;40955) then
                        return s__5foo[i-32764]
                    else
                        return s__6foo[i-40955]
                    endif
                elseif(i&lt;57337) then
                    return s__7foo[i-49146]
                else
                    return s__8foo[i-57337]
                endif
            elseif(i&lt;73719) then
                return s__9foo[i-65528]
            elseif(i&lt;90101) then
                if(i&lt;81910) then
                    return s__10foo[i-73719]
                else
                    return s__11foo[i-81910]
                endif
            elseif(i&lt;98292) then
                return s__12foo[i-90101]
            else
                return s__13foo[i-98292]
            endif
        elseif(i&lt;114674) then
            return s__14foo[i-106483]
        elseif(i&lt;155629) then
            if(i&lt;122865) then
                return s__15foo[i-114674]
            elseif(i&lt;139247) then
                if(i&lt;131056) then
                    return s__16foo[i-122865]
                else
                    return s__17foo[i-131056]
                endif
            elseif(i&lt;147438) then
                return s__18foo[i-139247]
            else
                return s__19foo[i-147438]
            endif
        elseif(i&lt;163820) then
            return s__20foo[i-155629]
        elseif(i&lt;180202) then
            if(i&lt;172011) then
                return s__21foo[i-163820]
            else
                return s__22foo[i-172011]
            endif
        elseif(i&lt;188393) then
            return s__23foo[i-180202]
        elseif(i&lt;196584) then
            return s__24foo[i-188393]
        else
            return s__25foo[i-196584]
        endif
    elseif(i&lt;212966) then
        return s__26foo[i-204775]
    elseif(i&lt;303067) then
        if(i&lt;221157) then
            return s__27foo[i-212966]
        elseif(i&lt;262112) then
            if(i&lt;229348) then
                return s__28foo[i-221157]
            elseif(i&lt;245730) then
                if(i&lt;237539) then
                    return s__29foo[i-229348]
                else
                    return s__30foo[i-237539]
                endif
            elseif(i&lt;253921) then
                return s__31foo[i-245730]
            else
                return s__32foo[i-253921]
            endif
        elseif(i&lt;270303) then
            return s__33foo[i-262112]
        elseif(i&lt;286685) then
            if(i&lt;278494) then
                return s__34foo[i-270303]
            else
                return s__35foo[i-278494]
            endif
        elseif(i&lt;294876) then
            return s__36foo[i-286685]
        else
            return s__37foo[i-294876]
        endif
    elseif(i&lt;311258) then
        return s__38foo[i-303067]
    elseif(i&lt;352213) then
        if(i&lt;319449) then
            return s__39foo[i-311258]
        elseif(i&lt;335831) then
            if(i&lt;327640) then
                return s__40foo[i-319449]
            else
                return s__41foo[i-327640]
            endif
        elseif(i&lt;344022) then
            return s__42foo[i-335831]
        else
            return s__43foo[i-344022]
        endif
    elseif(i&lt;360404) then
        return s__44foo[i-352213]
    elseif(i&lt;376786) then
        if(i&lt;368595) then
            return s__45foo[i-360404]
        else
            return s__46foo[i-368595]
        endif
    elseif(i&lt;384977) then
        return s__47foo[i-376786]
    elseif(i&lt;393168) then
        return s__48foo[i-384977]
    else
        return s__49foo[i-393168]
    endif
endfunction

function sg__foo_set takes integer i,integer v returns nothing
    if(i&lt;8191) then
        set s__foo<i>=v
    elseif(i&lt;204775) then
        if(i&lt;16382) then
            set s__2foo[i-8191]=v
        elseif(i&lt;106483) then
            if(i&lt;24573) then
                set s__3foo[i-16382]=v
            elseif(i&lt;65528) then
                if(i&lt;32764) then
                    set s__4foo[i-24573]=v
                elseif(i&lt;49146) then
                    if(i&lt;40955) then
                        set s__5foo[i-32764]=v
                    else
                        set s__6foo[i-40955]=v
                    endif
                elseif(i&lt;57337) then
                    set s__7foo[i-49146]=v
                else
                    set s__8foo[i-57337]=v
                endif
            elseif(i&lt;73719) then
                set s__9foo[i-65528]=v
            elseif(i&lt;90101) then
                if(i&lt;81910) then
                    set s__10foo[i-73719]=v
                else
                    set s__11foo[i-81910]=v
                endif
            elseif(i&lt;98292) then
                set s__12foo[i-90101]=v
            else
                set s__13foo[i-98292]=v
            endif
        elseif(i&lt;114674) then
            set s__14foo[i-106483]=v
        elseif(i&lt;155629) then
            if(i&lt;122865) then
                set s__15foo[i-114674]=v
            elseif(i&lt;139247) then
                if(i&lt;131056) then
                    set s__16foo[i-122865]=v
                else
                    set s__17foo[i-131056]=v
                endif
            elseif(i&lt;147438) then
                set s__18foo[i-139247]=v
            else
                set s__19foo[i-147438]=v
            endif
        elseif(i&lt;163820) then
            set s__20foo[i-155629]=v
        elseif(i&lt;180202) then
            if(i&lt;172011) then
                set s__21foo[i-163820]=v
            else
                set s__22foo[i-172011]=v
            endif
        elseif(i&lt;188393) then
            set s__23foo[i-180202]=v
        elseif(i&lt;196584) then
            set s__24foo[i-188393]=v
        else
            set s__25foo[i-196584]=v
        endif
    elseif(i&lt;212966) then
        set s__26foo[i-204775]=v
    elseif(i&lt;303067) then
        if(i&lt;221157) then
            set s__27foo[i-212966]=v
        elseif(i&lt;262112) then
            if(i&lt;229348) then
                set s__28foo[i-221157]=v
            elseif(i&lt;245730) then
                if(i&lt;237539) then
                    set s__29foo[i-229348]=v
                else
                    set s__30foo[i-237539]=v
                endif
            elseif(i&lt;253921) then
                set s__31foo[i-245730]=v
            else
                set s__32foo[i-253921]=v
            endif
        elseif(i&lt;270303) then
            set s__33foo[i-262112]=v
        elseif(i&lt;286685) then
            if(i&lt;278494) then
                set s__34foo[i-270303]=v
            else
                set s__35foo[i-278494]=v
            endif
        elseif(i&lt;294876) then
            set s__36foo[i-286685]=v
        else
            set s__37foo[i-294876]=v
        endif
    elseif(i&lt;311258) then
        set s__38foo[i-303067]=v
    elseif(i&lt;352213) then
        if(i&lt;319449) then
            set s__39foo[i-311258]=v
        elseif(i&lt;335831) then
            if(i&lt;327640) then
                set s__40foo[i-319449]=v
            else
                set s__41foo[i-327640]=v
            endif
        elseif(i&lt;344022) then
            set s__42foo[i-335831]=v
        else
            set s__43foo[i-344022]=v
        endif
    elseif(i&lt;360404) then
        set s__44foo[i-352213]=v
    elseif(i&lt;376786) then
        if(i&lt;368595) then
            set s__45foo[i-360404]=v
        else
            set s__46foo[i-368595]=v
        endif
    elseif(i&lt;384977) then
        set s__47foo[i-376786]=v
    elseif(i&lt;393168) then
        set s__48foo[i-384977]=v
    else
        set s__49foo[i-393168]=v
    endif
endfunction</i></i>
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Sevion's idea is n-dimension array, it is not Vex's array.
It is something like this.
JASS:
type Array1 extends integer array [80]
type Array2 extends Array1 array [80]
type Array3 extends Array2 array [80]

function test takes nothing returns nothing
    local Array3 lol = Array3.create()
    set lol[Array3.size][Array2.size][Array1.size] = 80
endfunction
 

Jesus4Lyf

Good Idea™
Reaction score
397
I prefer [ljass]array[1*2*3*4*5*6*7] = 1328;[/LJASS]
Which obviously fails, since 1*2 == 2*1, so storing in array[1][2] would overwrite storing in array[2][1].

There is a really nice way to do this using hashtables and array syntax.
Kingking's idea won't work nicely either, since you need to instantiate each array used.
Implementations are not the topic of this thread.

Are they useful? No. :)
 

Bribe

vJass errors are legion
Reaction score
67
I was just using one array to implement it.

How would you be able to overload an [] operator twice? Is there a way to detect it?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Implementations are not the topic of this thread.
This.
There is a really nice way to do this using hashtables and array syntax.
But, alright, it's simple.
JASS:
struct NArray
    method operator[] takes integer index returns thistype
        // commence pseudo code.
        local integer result = load from hashtable at (this, index).
        if result == 0 then
            set result = thistype.create()
            call save result in hashtable at (this, index).
        endif
        return result
    endmethod
    method operator []= takes integer index, integer value returns nothing
        call save value in hashtable at (this, index).
    endmethod
endstruct

You need to maintain a linked list for destroying stuff too, if you want them to be disposable.
Also, you can never store value 0 (<-- you can fix this using the has stored int native), or read from an array slot where you have not stored a value. There's a few other things, as well. :)

But seriously, back on topic, why? Why would you -ever- do this?..
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Kingking's idea won't work nicely either, since you need to instantiate each array used.
Yep, pretty troublesome. I reckoned 3d array is enough for people.
 

Sevion

The DIY Ninja
Reaction score
424
Hmm. Gathering from what I've read, it's not useful passed 2D Arrays.

But, Yap, I wasn't using the type method. :p

I was using the operator method.

I was using this:

JASS:
library MDA    
    //! textmacro NEWARRAY takes DIMENSION, NEXTDIMENSION, END
        struct array$DIMENSION$ extends array
            integer data
            static if $END$ then
                method operator [] takes integer index returns thistype
                return index
                endmethod
            else
                method operator [] takes integer index returns array$NEXTDIMENSION$
                    return index
                endmethod
            endif
            method operator []= takes integer index, integer data returns nothing
                set thistype(index).data = data
            endmethod
        endstruct
    //! endtextmacro
    
    //! runtextmacro NEWARRAY(&quot;10&quot;, &quot;0&quot;, &quot;true&quot;)
    //! runtextmacro NEWARRAY(&quot;9&quot;, &quot;10&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;8&quot;, &quot;9&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;7&quot;, &quot;8&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;6&quot;, &quot;7&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;5&quot;, &quot;6&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;4&quot;, &quot;5&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;3&quot;, &quot;4&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;2&quot;, &quot;3&quot;, &quot;false&quot;)
    
    struct MDA_array extends array
        integer data
        static method operator [] takes integer index returns array2
            return index
        endmethod
        method operator []= takes integer index, integer data returns nothing
            set thistype(index).data = data
        endmethod
    endstruct
endlibrary


Though, I wonder two things. What would be better/faster, Jesus's Hashtables, or my integer data? And what would the code look like processed? Hmm.
 

Jesus4Lyf

Good Idea™
Reaction score
397
What would be better/faster, Jesus's Hashtables, or my integer data? And what would the code look like processed? Hmm.
Consider that with mine, this is valid:
JASS:
local NArray arr = NArray.create()
set arr[GetHandleId(CreateTimer())][GetHandleId(GetTriggerUnit())][5][-200][90000]=2

With yours, it doesn't even work, so far as I can tell (??).
You just return the value passed into the [] operator?
 

tooltiperror

Super Moderator
Reaction score
231
The MDA Library compiles to:

JASS:
globals
//globals from MDA:
constant boolean LIBRARY_MDA=true
//endglobals from MDA


//JASSHelper struct globals:
constant integer si__array10=1
integer array s__array10_data
constant integer si__array9=2
integer array s__array9_data
constant integer si__array8=3
integer array s__array8_data
constant integer si__array7=4
integer array s__array7_data
constant integer si__array6=5
integer array s__array6_data
constant integer si__array5=6
integer array s__array5_data
constant integer si__array4=7
integer array s__array4_data
constant integer si__array3=8
integer array s__array3_data
constant integer si__array2=9
integer array s__array2_data
constant integer si__MDA_array=10
integer array s__MDA_array_data

endglobals


//library MDA:
    
//textmacro instance: NEWARRAY(&quot;10&quot;, &quot;0&quot;, &quot;true&quot;)

                function s__array10__getindex takes integer this,integer index returns integer
                return index
                endfunction





            function s__array10__setindex takes integer this,integer index,integer data returns nothing
                set s__array10_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;10&quot;, &quot;0&quot;, &quot;true&quot;)
//textmacro instance: NEWARRAY(&quot;9&quot;, &quot;10&quot;, &quot;false&quot;)





                function s__array9__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array9__setindex takes integer this,integer index,integer data returns nothing
                set s__array9_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;9&quot;, &quot;10&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;8&quot;, &quot;9&quot;, &quot;false&quot;)





                function s__array8__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array8__setindex takes integer this,integer index,integer data returns nothing
                set s__array8_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;8&quot;, &quot;9&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;7&quot;, &quot;8&quot;, &quot;false&quot;)





                function s__array7__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array7__setindex takes integer this,integer index,integer data returns nothing
                set s__array7_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;7&quot;, &quot;8&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;6&quot;, &quot;7&quot;, &quot;false&quot;)





                function s__array6__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array6__setindex takes integer this,integer index,integer data returns nothing
                set s__array6_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;6&quot;, &quot;7&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;5&quot;, &quot;6&quot;, &quot;false&quot;)





                function s__array5__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array5__setindex takes integer this,integer index,integer data returns nothing
                set s__array5_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;5&quot;, &quot;6&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;4&quot;, &quot;5&quot;, &quot;false&quot;)





                function s__array4__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array4__setindex takes integer this,integer index,integer data returns nothing
                set s__array4_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;4&quot;, &quot;5&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;3&quot;, &quot;4&quot;, &quot;false&quot;)





                function s__array3__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array3__setindex takes integer this,integer index,integer data returns nothing
                set s__array3_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;3&quot;, &quot;4&quot;, &quot;false&quot;)
//textmacro instance: NEWARRAY(&quot;2&quot;, &quot;3&quot;, &quot;false&quot;)





                function s__array2__getindex takes integer this,integer index returns integer
                    return index
                endfunction

            function s__array2__setindex takes integer this,integer index,integer data returns nothing
                set s__array2_data[(index)]=data
            endfunction
//end of: NEWARRAY(&quot;2&quot;, &quot;3&quot;, &quot;false&quot;)
    
        function s__MDA_array__staticgetindex takes integer index returns integer
            return index
        endfunction
        function s__MDA_array__setindex takes integer this,integer index,integer data returns nothing
            set s__MDA_array_data[(index)]=data
        endfunction

//library MDA ends
function main takes nothing returns nothing

call ExecuteFunc(&quot;jasshelper__initstructs2030&quot;)

endfunction



//Struct method generated initializers/callers:

function jasshelper__initstructs2030 takes nothing returns nothing











endfunction
 

Nestharus

o-o
Reaction score
84
Well, it would be useful if the language had tools that allowed you to pull it off..

I mean, how can you do an n-dimensional array algorithm using the preprocessing tools provided by vjass?

How can you do this for example?
[ljass][[d1a, d1b, d1c], [d2a, d2b, d2c, d2d], d3, [d4a, d4b]][/ljass]

I always write it out by hand ; D.
 

Sevion

The DIY Ninja
Reaction score
424
Jesus, this worked for me:

JASS:
    function test takes nothing returns nothing
        set MDA_array[GetHandleId(CreateTimer())][GetHandleId(GetTriggerUnit())][5][-200][90000]=2
    endfunction


Note: With MDA, you don't create your own variable. You use the struct name directly.

Though, I'm not exactly sure how the -200 and 90000 would play out. I'm guessing the 90000 would turn into JH's ugly array limit bypass.

Edit:

JASS:
library MDA    
    //! textmacro NEWARRAY takes DIMENSION, NEXTDIMENSION, END
        struct array$DIMENSION$ extends array
            integer data
            static if $END$ then
                method operator [] takes integer index returns thistype
                    return thistype(index).data
                endmethod
            else
                method operator [] takes integer index returns array$NEXTDIMENSION$
                    return index
                endmethod
            endif
            method operator []= takes integer index, integer data returns nothing
                set thistype(index).data = data
            endmethod
        endstruct
    //! endtextmacro
    
    //! runtextmacro NEWARRAY(&quot;4&quot;, &quot;0&quot;, &quot;true&quot;)
    //! runtextmacro NEWARRAY(&quot;3&quot;, &quot;4&quot;, &quot;false&quot;)
    //! runtextmacro NEWARRAY(&quot;2&quot;, &quot;3&quot;, &quot;false&quot;)
    
    struct MDA_array extends array
        integer data
        static method operator [] takes integer index returns array2
            return index
        endmethod
        method operator []= takes integer index, integer data returns nothing
            set thistype(index).data = data
        endmethod
    endstruct
endlibrary

scope Test initializer test
    function test takes nothing returns nothing
        local integer i
        set i = GetHandleId(CreateTimer())
        set MDA_array<i>[5][-200][8191]=2
        set i = GetHandleId(CreateTimer())
        set MDA_array<i>[5][-199][1531]=3
        set i = GetHandleId(CreateTimer())
        set MDA_array<i>[5][-198][8116]=4
        set i = GetHandleId(CreateTimer())
        set MDA_array<i>[5][-197][3457]=5
        set i = GetHandleId(CreateTimer())
        set MDA_array<i>[5][-200][14]=6
        call BJDebugMsg(&quot;Value: &quot; + I2S(MDA_array<i>[5][-200][8191]))
        call BJDebugMsg(&quot;Value: &quot; + I2S(MDA_array<i>[5][-199][1531]))
        call BJDebugMsg(&quot;Value: &quot; + I2S(MDA_array<i>[5][-198][8116]))
        call BJDebugMsg(&quot;Value: &quot; + I2S(MDA_array<i>[5][-197][3457]))
        call BJDebugMsg(&quot;Value: &quot; + I2S(MDA_array<i>[5][-200][14]))
    endfunction
endscope
</i></i></i></i></i></i></i></i></i></i>


This works completely. Though, each dimension is limited to 8192. I suppose JH's array limit bypass doesn't work with this. Also, you can only currently recover data from the "last" dimension. Something that needs to be fixed >_<
 

Nestharus

o-o
Reaction score
84
I assume that I'm totally lost in this conversation because you guys aren't actually talking about multidimensional arrays?

It looks like you are talking about them by the titles, but then the code looks like jagged arrays...

Are you guys talking about jagged or multidimensional?

if you are talking about jagged (by the looks of your code), then this is possible. if you are talking about multidimensional as per the descriptions, then this isn't possible with the current vjass tools.

From wikipedia

Multidimensional arrays

For a two-dimensional array, the element with indices i,j would have address B + c · i + d · j, where the coefficients c and d are the row and column address increments, respectively.

More generally, in a k-dimensional array, the address of an element with indices i1, i2, …, ik is

B + c1 · i1 + c2 · i2 + … + ck · ik

This formula requires only k multiplications and k?1 additions, for any array that can fit in memory. Moreover, if any coefficient is a fixed power of 2, the multiplication can be replaced by bit shifting.

The coefficients ck must be chosen so that every valid index tuple maps to the address of a distinct element.

If the minimum legal value for every index is 0, then B is the address of the element whose indices are all zero. As in the one-dimensional case, the element indices may be changed by changing the base address B. Thus, if a two-dimensional array has rows and columns indexed from 1 to 10 and 1 to 20, respectively, then replacing B by B + c1 - ? 3 c1 will cause them to be renumbered from 0 through 9 and 4 through 23, respectively. Taking advantage of this feature, some languages (like FORTRAN 77) specify that array indices begin at 1, as in mathematical tradition; while other languages (like Fortran 90, Pascal and Algol) let the user choose the minimum value for each index.

jagged
An alternative to a multidimensional array structure is to use a one-dimensional array of references to arrays of one dimension less. For two dimensions, in particular, this alternative structure would be a vector of pointers to vectors, one for each row. Thus an element in row i and column j of an array A would be accessed by double indexing (A[j] in typical notation). This alternative structure allows ragged or jagged arrays, where each row may have a different size — or, in general, where the valid range of each index depends on the values of all preceding indices. It also saves one multiplication (by the column address increment) replacing it by a bit shift (to index the vector of row pointers) and one extra memory access (fetching the row address), which may be worthwhile in some


I hope you guys can understand why I am so confused = )

This
[ljass]set MyMultiDimensionalArray[1][2][3][4][5][6][7] = 1328[/ljass]

Is a jagged array

this
[ljass]set MyMultiDimensionalArray[1,2,3,4,5,6,7] = 1328[/ljass]

Is a multidimensional array

I assumed, because vjass doesn't support [,], that you were just using [][] to create multidimensional, but the code confused the heck out of me : D. Wasn't sure why you weren't just using little matrix algorithms ; P.
 

Nestharus

o-o
Reaction score
84
Are you going to make me say it again?

THIS IS NOT C#. OKAY?

jagged is not a term specifically for c#... it's a regular programming term -.-...

I assumed that my above definitions, which don't mention c# anywhere, made that clear.

Let me make it very simple
A jagged array is merely an array that's made up of arrays


So you guys are talking about jagged arrays right?

If that is the case, then what you are doing is pretty cool and useful sevion : P (which I think it is).

If you guys are really gunning for multidimensional, then you'd probably have to change the code around a lot : O, and I don't know how you'd pull that off with vjass.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top