From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: List Container Strawman 1.4
Date: Fri, 28 Dec 2001 19:12:25 -0000
Date: 2001-12-28T19:12:25+00:00 [thread overview]
Message-ID: <a0ig4g$ktm9v$1@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 3C2CA143.6030006@mail.com
"Hyman Rosen" <hyrosen@mail.com> wrote in message
news:3C2CA143.6030006@mail.com...
> Ted Dennison wrote:
>
> > Actually, I was thinking along the lines of an Containers.Lists.Fixed
>
> > package that works with arrays.
>
> I think this kind of thing is where C++'s iterators and algorithms
> approach shows its superiority. Why should a List have any notion
> of other data structures to which its elements can be copied?
>
> In the STL, creating or copying one structure from another can be
> done just using the std::copy algorithm, a pair of iterators giving
> the source range, and a target iterator which receives the copies.
> If you want to copy to a fixed-size array, the target iterator can
> simply be a pointer to the first element. If you are creating a more
> complicated target (such as another list, or a vector), then it is
> the iterator that holds the semantics of where the data goes, for
> example std::inserter or std::back_inserter.
Well, speaking for what my own library (which I'm calling Tenet) will
provide, I am supplying a set of container-wide iterator types, which come
with a Copy_All procedure. So if I have, say, a lookup and a list, I can
copy from one to the other thus:
package Widget_Lookups is new Tenet.Lookups.Unbounded(Widget);
package Widget_Lists is new Tenet.Lists.Unbounded(Widget);
M: Widget_Lookups.Lookup;
L: Widget_Lists.List;
package Widget_Iteration is Tenet.Iteration(Widget);
package Widget_Lookup_Iteration is new
Widget_Lookups.Iteration(Widget_Iteration);
package Widget_List_Iteration is new
Widget_Lists.Iteration(Widget_Iteration);
R: Widget_Lookup_Iteration.Reader;
W: Widget_List_Iteration.Writer;
...
Open(R,M);
Open(W,L);
Copy_All(R,W);
Close(W);
Close(R);
It is all very wordy. The C++ equivalent is no doubt more concise. But, of
course, this is only a tiny example. Realler software would show (IMHO ;-)
the expressiveness of this design. In a hurry; must go.
--
Best wishes,
Nick Roberts
next prev parent reply other threads:[~2001-12-28 19:12 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-13 3:23 List Container Strawman 1.4 Ted Dennison
2001-12-13 18:11 ` Brian Hanson
2001-12-13 23:02 ` Nick Roberts
2001-12-14 15:19 ` Ted Dennison
2001-12-14 23:54 ` Ted Dennison
2001-12-15 2:06 ` Server - tasking and long lived connections Eric Merritt
2001-12-15 3:10 ` James Rogers
2001-12-15 12:10 ` Florian Weimer
2001-12-15 14:38 ` Larry Kilgallen
2001-12-15 16:51 ` Steve Doiel
2001-12-17 9:15 ` Thierry Lelegard
2001-12-17 9:34 ` Jean-Pierre Rosen
2001-12-17 10:16 ` Thierry Lelegard
2001-12-18 9:08 ` Jean-Pierre Rosen
2001-12-17 15:08 ` Larry Kilgallen
2001-12-17 15:39 ` Pat Rogers
2001-12-19 18:20 ` Matthew Heaney
2001-12-19 18:50 ` Eric Merritt
2001-12-15 1:20 ` List Container Strawman 1.4 Nick Roberts
2001-12-15 20:29 ` Ted Dennison
2001-12-16 18:45 ` Nick Roberts
2001-12-21 15:53 ` Ted Dennison
2001-12-21 16:42 ` Marin David Condic
2001-12-21 18:28 ` Ted Dennison
2001-12-21 18:47 ` Marin David Condic
2001-12-21 19:39 ` Ted Dennison
2001-12-21 19:48 ` Marin David Condic
2001-12-22 12:29 ` Simon Wright
2001-12-21 20:03 ` Nick Roberts
2001-12-21 16:52 ` Marin David Condic
2001-12-21 18:41 ` Ted Dennison
2001-12-21 19:14 ` Marin David Condic
2001-12-21 21:13 ` Ted Dennison
2001-12-22 5:34 ` John B. Matthews
2001-12-21 20:19 ` Stephen Leake
2001-12-21 21:35 ` Ted Dennison
2001-12-24 11:58 ` Florian Weimer
2001-12-24 14:42 ` Eric Merritt
2001-12-24 22:47 ` Ted Dennison
2001-12-25 22:15 ` Florian Weimer
2001-12-28 13:58 ` Ted Dennison
2001-12-21 17:43 ` Stephen Leake
2001-12-21 18:44 ` Ted Dennison
2001-12-16 21:53 ` Larry Hazel
2001-12-15 22:27 ` Ted Dennison
2001-12-16 4:32 ` Darren New
2001-12-24 13:53 ` Florian Weimer
2001-12-15 23:19 ` Florian Weimer
2001-12-16 4:46 ` Ted Dennison
2001-12-24 13:57 ` Florian Weimer
2001-12-28 14:00 ` Ted Dennison
2001-12-28 16:43 ` Hyman Rosen
2001-12-28 19:12 ` Nick Roberts [this message]
2001-12-28 19:49 ` Matthew Heaney
2001-12-29 23:23 ` Matthew Heaney
2001-12-30 6:31 ` Hyman Rosen
2002-01-03 0:09 ` Matthew Heaney
2002-01-03 0:20 ` Brian Rogoff
2001-12-17 8:34 ` Mark Lundquist
2001-12-18 21:56 ` Florian Weimer
2001-12-18 21:54 ` Larry Kilgallen
2001-12-18 22:34 ` Mark Lundquist
2001-12-19 4:03 ` Nick Roberts
2001-12-24 13:54 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox