Results 1 to 4 of 4

Thread: tri-dimension Array alternatives

  1. #1

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    tri-dimension Array alternatives

    Hi All,

    I am looking at options for holding multiple sets of 3 elements of data to represent a 'Starry Background' (x and y co-ordinates and a colour value - all integers).

    I was fine with an Array for x and y (int stararry[600][1]) prior to adding the colour component.

    I could use a tri-dimensional Array but that could use a ton of memory.
    I could use 3 seperate Arrays (each [600]). One for x, one for y and one for colour.


    Idea's?



    Cheers,

  2. #2

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: tri-dimension Array alternatives

    Ok, possibly a Structure?
    Code:
    typedef struct starAtributes 
    {
       int x, y, colour;
    } starAtributes;
    
    
    starAtributes stars[600];
    Last edited by Bruce Fox; Jul 24th, 2006 at 08:18 PM.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: tri-dimension Array alternatives

    What makes you think it'll use less memory just because you use a different way of denoting the exact same structure? As long as you have 600 stars, and each star has a x, y and color components, and each of these components is 4 bytes large, you'll use 7200 bytes of memory - which is not that much, btw.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: tri-dimension Array alternatives

    My concern was with the tri-state Array. Since then I realised I could use a structure.
    I now see that the two will consume the same amount of memory.

    The structure (stars) is easier to use too.


    Cheers,

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