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

This is a discussion on How do you make a 2D array that maps efficiently? within the C++ Programming forums, part of the General Programming Boards category; 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] ...

  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, 04:50 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 11: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, 10:48 AM
  5. 2d Array access by other classes
    By deaths_seraphim in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2001, 09:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21