comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Question about arrays and no. of elements
Date: Thu, 15 May 2008 10:52:12 -0700 (PDT)
Date: 2008-05-15T10:52:12-07:00	[thread overview]
Message-ID: <3efb9f23-bd5e-48d0-bbc6-660cdc757c69@k1g2000prb.googlegroups.com> (raw)
In-Reply-To: b60e9537-ab45-4856-99de-71127208813f@56g2000hsm.googlegroups.com

On May 15, 8:19 am, amal.alpho...@gmail.com wrote:
> If I define an array with say a million elements, and I only put data
> in 10 of them, is it actually a waste of space/time with the array or
> does Ada only create elements when there is data to put in (so it is
> efficient)?

"Ada" the language doesn't really dictate how arrays are represented,
but I think that any existing Ada compiler will allocate storage for a
million elements.  This may be a waste of space, but I don't
understand why you think it would be a waste of time: it is *more*
efficient, time-wise, to do it this way, because determining the
location of a particular array element is very simple, while any
scheme that tries to allocate memory only for elements actually used
is going to require significant overhead.

                                -- Adam




  parent reply	other threads:[~2008-05-15 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 15:19 Question about arrays and no. of elements amal.alphonse
2008-05-15 16:30 ` gautier_niouzes
2008-05-15 16:50 ` anon
2008-05-15 17:52 ` Adam Beneschan [this message]
2008-05-16  9:50 ` Ken Thomas
2008-05-17 14:20 ` Steve
2008-05-17 16:32 ` Jacob Sparre Andersen
2008-05-17 17:37   ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox