Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Storing large number of values in 2D array

Reply
Thread Tools

Storing large number of values in 2D array

 
 
Andrey Tarasevich
Guest
Posts: n/a
 
      10-20-2006
rajus wrote:
> I want to store the (x,y) coordinates of about 10,000 points in a 2D
> array.How can I store them and retrieve them later?


Well, declare a 2D array of points. Store points in the array. Retireve them
later from the array. What exactly is the problem that makes you ask such a
trivial question?

--
Best regards,
Andrey Tarasevich
 
Reply With Quote
 
 
 
 
jacob navia
Guest
Posts: n/a
 
      10-20-2006
Al Balmer wrote:
> On Fri, 20 Oct 2006 20:46:28 +0200, jacob navia
> <(E-Mail Removed)> wrote:
>
>
>>rajus wrote:
>>
>>>I want to store the (x,y) coordinates of about 10,000 points in a 2D
>>>array.How can I store them and retrieve them later?
>>>

>>
>>You have 10 000 x 2 points i.e. 20 000 points to store.
>>To minimize space you could use 12 bits (coordinates up
>>to 4096x4096) and store 5 points per 64 bits, making it
>>around 32 000 bytes for the 2D array.

>
>
> Of course, the extra code required to do this would probably make up
> for the saved space. I like Lew's suggestion, using whatever size
> integer is appropriate.
>


I do not think that a simple code for accessing a 2D 12 bit
integer array would make 14 000 bytes of code in C.
At most it would take 150-200 bytes of code, maybe more in RISC
processors, but never 12 000 bytes.

But that was a memory efficient solution, good for embedded
systems where memory considerations are important.

I proposed also a 16 bit solution, not knowing precisely the context.

What is important to emphasize is that integers of bit-size other
than 8-16-32 are possible, and can be a space saving in many situations.

I have seen proposals to add to C
int:12 a;

meaning a is a 12 bit integer. This, with support for array notation of
those integers would be interesting in systems where memory is important

jacob
 
Reply With Quote
 
 
 
 
Al Balmer
Guest
Posts: n/a
 
      10-20-2006
On Fri, 20 Oct 2006 14:04:48 -0700, Andrey Tarasevich
<(E-Mail Removed)> wrote:

>rajus wrote:
>> I want to store the (x,y) coordinates of about 10,000 points in a 2D
>> array.How can I store them and retrieve them later?

>
>Well, declare a 2D array of points. Store points in the array. Retireve them
>later from the array. What exactly is the problem that makes you ask such a
>trivial question?


Trivial questions are not unwelcome here.

However, your question, "What exactly is the problem", is certainly
pertinent here, and the answer to that might make the original
question less trivial

--
Al Balmer
Sun City, AZ
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting values in an array, storing in a hash then making an arrayof hashes? Jen Ruby 3 03-23-2011 12:11 PM
Storing and displaying numbers the indicies of number that appear 3+times in an array at O(n*logn) or better perditi0n2002 C Programming 4 01-02-2011 08:31 AM
Storing values that are too large for that data type Albert C Programming 11 01-31-2009 01:19 AM
Storing values to array trickish@gmail.com C++ 3 11-09-2005 10:08 PM
storing values from file into an array.-newbie Go Perl Perl Misc 3 10-20-2003 11:59 PM



Advertisments