From: Duncan Sands <baldrick@free.fr>
To: Georg Bauhaus <bauhaus@futureapps.de>
Cc: comp.lang.ada@ada-france.org
Subject: Re: Ada.Containers.Vectors - querying multiple elements
Date: Tue, 26 Apr 2005 16:39:38 +0200
Date: 2005-04-26T16:39:38+02:00 [thread overview]
Message-ID: <mailman.78.1114526397.24457.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <426e4c2b$0$7515$9b4e6d93@newsread2.arcor-online.net>
Hi Georg, thanks for replying.
> > procedure Query_Elements
> > (Container : in Vector;
> > First_Index : in Index_Type;
> > Last_Index : in Extended_Index;
> > Process : not null access procedure (Elements : in Element_Array));
>
>
> > It would be good to have for both
> > efficiency reasons and simple implementation of certain classes of algorithms.
> > In my case I have a "divide and conquer" recursive algorithm which while it
> > can be written using the current package, would be simpler to write if something
> > like Query_Elements existed.
>
> Couldn't you use Cursors,
>
> here: Cursor := find_or_something(container, ...);
> there: constant Cursor := find_or_something(container, ...);
>
> while here /= there loop
> ...
> next(here);
> end loop;
I'm particularly concerned about:
(1) efficiency - suppose (for example) I want to transmit the contents
of my vector down a socket. Then I would have to do an element-by-
element copy into a buffer (using code like you suggest), and then send
the buffer. The element-by-element copy is inefficient, and with a
procedure like Query_Elements above simply wouldn't (necessarily) be
needed. An element-by-element copy can't compete with memcpy (what
you'd probably get if you copied a slice directly, which would be
possible using Query_Elements), and certainly can't compete with no
copy at all. By the way, this is not a real example, it's just the
first thing that came to mind. In any case, it is a special case of
point (2):
(2) reuse of legacy code - I don't know about you, but I've a lot of
legacy code around that takes an array as a parameter. I mean code
that doesn't change the length of the array (or anything like that) -
code that just operates on the array in-place. Suppose I am using
a Vector, and want to have some legacy code operate on it, or on
part of it. Right now I would have to copy the appropriate part of
the Vector into a buffer, and pass that to the legacy code, and then
copy it back. Not very efficient - and not necessary if the Vectors
api was extended slightly.
Ciao,
D.
next prev parent reply other threads:[~2005-04-26 14:39 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-26 11:43 Ada.Containers.Vectors - querying multiple elements Duncan Sands
2005-04-26 14:12 ` Georg Bauhaus
2005-04-26 14:39 ` Duncan Sands [this message]
2005-04-26 15:44 ` Matthew Heaney
2005-04-26 16:05 ` Duncan Sands
[not found] ` <1114531544.32583.142.camel@localhost.localdomain>
[not found] ` <426E72C3.9070108@on2.com>
2005-04-26 16:59 ` Duncan Sands
[not found] ` <1114534751.32583.144.camel@localhost.localdomain>
[not found] ` <426E73DE.2070505@on2.com>
2005-04-26 17:08 ` Duncan Sands
2005-04-26 18:17 ` Martin Dowie
2005-04-26 18:48 ` Duncan Sands
2005-04-26 18:59 ` Duncan Sands
2005-04-26 19:05 ` Georg Bauhaus
2005-04-26 20:34 ` Duncan Sands
2005-04-26 21:47 ` Dr. Adrian Wrigley
2005-04-26 23:21 ` Marius Amado Alves
[not found] ` <9decddc0038674b3c85aeceefb4d3b83@netcabo.pt>
2005-04-27 8:15 ` Duncan Sands
[not found] ` <1114589729.10418.13.camel@localhost.localdomain>
2005-04-27 11:49 ` Marius Amado Alves
2005-04-28 0:36 ` Randy Brukardt
2005-04-28 7:09 ` Duncan Sands
2005-04-27 11:10 ` Georg Bauhaus
2005-04-27 11:57 ` Duncan Sands
2005-04-28 14:17 ` Duncan Sands
2005-04-27 4:59 ` Jeffrey Carter
2005-04-27 7:21 ` Duncan Sands
2005-04-28 2:54 ` Jeffrey Carter
2005-04-28 7:15 ` Duncan Sands
2005-04-28 12:27 ` Matthew Heaney
2005-04-28 13:18 ` Matthew Heaney
2005-04-28 13:53 ` Duncan Sands
2005-04-29 2:46 ` Jeffrey Carter
2005-04-29 18:22 ` Robert A Duff
2005-04-28 7:18 ` Duncan Sands
2005-04-28 0:33 ` Randy Brukardt
2005-04-28 3:09 ` Jeffrey Carter
2005-04-28 20:55 ` Randy Brukardt
2005-04-29 2:54 ` Jeffrey Carter
2005-04-29 18:34 ` Robert A Duff
2005-04-29 20:18 ` Randy Brukardt
2005-04-29 20:00 ` Randy Brukardt
2005-04-30 4:06 ` Jeffrey Carter
2005-04-29 7:52 ` Dmitry A. Kazakov
2005-04-29 20:26 ` Randy Brukardt
2005-04-30 9:24 ` Dmitry A. Kazakov
2005-05-02 3:21 ` Randy Brukardt
2005-05-02 17:04 ` Dmitry A. Kazakov
2005-05-02 18:57 ` Robert A Duff
2005-05-03 8:14 ` Dmitry A. Kazakov
2005-05-03 23:30 ` Robert A Duff
2005-05-05 10:51 ` Dmitry A. Kazakov
2005-05-07 1:20 ` Matthew Heaney
2005-05-07 7:17 ` Dmitry A. Kazakov
[not found] <1114515832.32583.41.camel@localhost.localdomain>
[not found] ` <426E5A0B.3010109@on2.com>
2005-04-26 16:00 ` Duncan Sands
2005-04-28 0:54 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox