Shop OBEX P1 Docs P2 Docs Learn Events
1-dimensional array — Parallax Forums

1-dimensional array

RuRu Posts: 2
edited 2004-09-02 22:36 in General Discussion
In the URL below, it states that a limitation of the Javelin is that is only uses 1-dimensional arrays?
http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part3/Chapter23/Javelin.html

How can I use the index to simulate 2-D arrays?

Does this mean that image processes with the Javelin is out of the question?

-Ru

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-09-02 22:36
    You can use as many dimensions as you like but you

    must do the index calculation yourself.

    For example a 2-dimensional array myArray[noparse][[/noparse]12][noparse][[/noparse]5]

    This will have 60 entries so you define

    int[noparse]/noparse myArray = new int[noparse][[/noparse]12*5]; //indexes 0 to 59

    To index using [noparse][[/noparse]x][noparse][[/noparse]y] you calculate

    int index = x*5 + y

    where x is 0 to 11 and y is 0 to 4



    regards peter
Sign In or Register to comment.