From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Performance of element access in Vector
Date: Wed, 21 Jan 2009 20:00:56 +0100
Date: 2009-01-21T20:00:58+01:00 [thread overview]
Message-ID: <jnwc1vv3vzmb$.j78h3mz0a049.dlg@40tude.net> (raw)
In-Reply-To: 15dd6f2b-0d9d-42d0-9c7a-c17bc348434f@x16g2000prn.googlegroups.com
On Wed, 21 Jan 2009 05:14:17 -0800 (PST), Maciej Sobczak wrote:
> On 21 Sty, 11:19, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>
>>> You mean that arrays have the Iterate method?
>>
>> The language Ada has iteration methods, for example for-loop.
>
> No, for-loops are not iteration methods, they are control structures.
They are methods of iteration. You mean that for-loop is not a primitive
operation of array. Why should it be?
> Iteration methods are defined by particular interfaces and these are
> different for arrays and Vectors.
Yes, as an ugly hack container libraries provide "foreach" as a primitive
operation. It is even so ugly because neither Ada nor C++ support multiple
dispatch in order to make such a primitive operation truly primitive for
both the container and the element, or maybe for three, including
index/cursor.
>>>> Ordered containers must have array interface.
>>
>>> You mean that containers overload the () indexing? I'm afraid they don't.
>>
>> That containers implement element access using an index from 1D space, if
>> we are talking about iterations.
>
> This similarity can be interesting as a theory, but is useless in
> practice.
I don't see any problems. For-loops were in practical use long before any
container libraries.
> Can you *reuse* a piece of code that traverses an array (or Vector)
> and apply it to a Vector (or array, respectively)?
You wrap for-loop into a procedure, that is.
> There are two reuse mechanisms in Ada, one with class-wide types and
> run-time polymorphism and one with generics. Neither one can be
> applied to the arrays vs. Vectors problem.
Why? It is trivial to define a primitive operation containing a loop.
> That's why, as far as I'm concerned, arrays and Vectors do not share
> any interface.
They shall share array interface when ordered.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2009-01-21 19:00 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
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 [this message]
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