comp.lang.ada
 help / color / mirror / Atom feed
From: george.priv@gmail.com
Subject: Re: Performance of element access in Vector
Date: Wed, 21 Jan 2009 11:25:04 -0800 (PST)
Date: 2009-01-21T11:25:04-08:00	[thread overview]
Message-ID: <edac070e-bc97-4665-8279-5b82ff55dfb8@b1g2000yqg.googlegroups.com> (raw)
In-Reply-To: 4c38e681-3996-4ce9-ad33-6f7bd790fdbf@u18g2000pro.googlegroups.com

On Jan 21, 3:52 am, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 20 Sty, 23:07, george.p...@gmail.com wrote:
>
> > Unlike C++ for simple objects I don't see advantage of using vectors
> > vs. arrays in Ada. Only that it provide uniform ways to traverse
> > through all containers?  Anything else I am missing?
>
> Growing/shrinking.
>
> Vector can be built by appending without prior knowledge of the
> element count. Think about reading data from files, databases, etc.
> This is probably the most useful feature of this data structure.
> Of course, it is also useful for element removal - Vector
> automatically tracks its size. When compared to this, messing around
> with explicit length (i.e. how many elements are "used" in the raw
> array) management is too error prone.
>

Letting vector grow causes unpredictable run-time penalties.
Inserting/deleting elements can be time consuming.  If worse come to
worse these can be addressed in totally different programming paradigm
foreign to C++.

> In other words, Vector is not only dynamic, it is also self-conscious.
>
> In C++ the only real reason to frown upon vector is in high-integrity
> or constrained environments because of the dynamic memory issues.
> Otherwise, in a general-purpose programming, it is superior to raw
> arrays in 95% of cases and recommended as a "default" array-like
> container. It also guarantees continuous storage, which makes it a
> very nice direct I/O buffer - although this is not widely recognized.
>

Agree

> For someone coming from the C++ universe the inability of Vectors in
> Ada to do all these things with comparable performance is
> disappointing and it looks like the notion of reference as a first-
> class program entity is crucial here.
>

If you just try to get away from C++ paradigm you can find other ways
to address these issues with raw arrays.  Think in functional
programming framework for a change.

George


> --
> Maciej Sobczak *www.msobczak.com*www.inspirel.com
>
> Database Access Library for Ada:www.inspirel.com/soci-ada




  reply	other threads:[~2009-01-21 19:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 21:42 Performance of element access in Vector Maciej Sobczak
2009-01-19  0:03 ` george.priv
2009-01-19  3:23 ` george.priv
2009-01-19 11:25   ` Georg Bauhaus
2009-01-19 16:32   ` (see below)
2009-01-20  2:17 ` Randy Brukardt
2009-01-20  8:03   ` Maciej Sobczak
2009-01-20  8:26     ` Dmitry A. Kazakov
2009-01-20 22:07       ` george.priv
2009-01-21  8:52         ` Maciej Sobczak
2009-01-21 19:25           ` george.priv [this message]
2009-01-22 10:01             ` Georg Bauhaus
2009-01-22 12:43               ` Maciej Sobczak
2009-01-22 13:52               ` george.priv
2009-01-21  8:59         ` Dmitry A. Kazakov
2009-01-21  9:19           ` Maciej Sobczak
2009-01-21 10:19             ` Dmitry A. Kazakov
2009-01-21 13:14               ` Maciej Sobczak
2009-01-21 19:00                 ` Dmitry A. Kazakov
2009-01-21 13:22             ` Georg Bauhaus
2009-01-23 14:56         ` Alex R. Mosteo
2009-01-20 23:01   ` Randy Brukardt
2009-01-21  9:15     ` Maciej Sobczak
2009-01-21 18:08       ` Georg Bauhaus
2009-01-23 14:55         ` Alex R. Mosteo
2009-01-23 17:30           ` Georg Bauhaus
replies disabled

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