Thread: How do you make a 2D array that maps efficiently?

  1. #1
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73

    How do you make a 2D array that maps efficiently?

    Hi guys, I'm making a 2D int array (int array[400][400]) inside a class and i'm trying to map each [x][y] to a separate key, which i use to insert some object into a map. My question is, what is the most efficient way of doing this? i've written so far a 3 for loop inserting a unique key per [x][y] and using it later on -- and this seems to be very slow.

    i'm setting up a pixel by pixel window mapping with an r g b value -- whats the fastest way?

  2. #2
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    erm..nvrmnd...

    i did this ..

    int r = 0;
    for i to maxrow
    for j to maxcol
    array( i,j )= r++

    now i got 2 for loops instead of 3 nevermind!! <3 and they all have unique keys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiplying a 2D array by a 1D array
    By youngvito in forum C Programming
    Replies: 14
    Last Post: 06-12-2009, 03:50 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Comparing a 2d Array (newbie)
    By Cockney in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2001, 12:15 PM
  4. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM
  5. 2d Array access by other classes
    By deaths_seraphim in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2001, 08:05 AM