Results 1 to 7 of 7

Thread: [RESOLVED] 3 Dimensional arrays...

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [RESOLVED] 3 Dimensional arrays...

    Ok, I just had the same problem in Python, and I know I always used to mix this in C++ and C# too, so it is probably much simpler then it looks like right now.

    What I want to know is the syntax to first make a 2D array. Then I want to make a an other one dimensional array, and make one of the elements in the first one point to the other array, something like:

    my2DArray[2,2] = my1DArray;
    my2DArray[2,3] = anOther1DArrray;


    is this doable....if so, how? Jagged array or?

    - ØØ -

  2. #2

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] 3 Dimensional arrays...

    This looks pretty stupid, but at least it looks like it works...

    Code:
                TestObj[][][] test;
                test = new TestObj[4][][];
                test[0] = new TestObj[4][];
                test[0][1] = new TestObj[10];
                test[0][1][7] = new TestObj();
                test[0][1][7].X = 3;

    - ØØ -

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [RESOLVED] 3 Dimensional arrays...

    int[] One = new int[10];
    int[,] Two = new int[10,10];

    Two[0,0] = One[0];
    Two[0,1] = One[1];
    Two[0,2] = One[2];
    Two[0,3] = One[3];
    ...


    ?????

    According to MSDN, jagged arrays are much more efficiently handled by the CLR than normal rectangular arrays.
    I don't live here any more.

  4. #4

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] 3 Dimensional arrays...

    But what you did now is not a 3D array. It is a 2D array...


    What you would have to do is this:

    int[] One1 = new int[10];
    int[] One2 = new int[10];
    int[] One3 = new int[10];
    int[,] Two = new int[10,10];

    Two[0,0] = One1;
    Two[0,1] = One2;
    Two[0,2] = One3;


    How would you do that with jagged arrays? It is har to find the right syntax here since you can't see the difference on a one dimentional jagged array or a one dimmentional normal array....hmmm-.....

    - ØØ -

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] 3 Dimensional arrays...

    HAhaha...light just got turned on..


    Code:
                int[] One = new int[10];
                int[,][] Two = new int[10, 10][];
    
                Two[0, 0] = One;
    Ugly as hell, but it looks like it is working..

    PS: I have lost the count on how many times I should rate you though...



    - ØØ -

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [RESOLVED] 3 Dimensional arrays...

    Ahhhhhh now I see what you wanted.

    I have also lost count of how many times you should have rated me.

    I still need to spread the love before I can hit you again though.
    I don't live here any more.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] 3 Dimensional arrays...

    Hehe..yeah...the spread is always a pain in the ass...but at least this is working now...but the 3D point -> polygon code is not...grrrrrrrr...you have NOOO idea how many pieces of papers I have used for this project...grrr..


    - ØØ -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width