From: Stephen Leake <Stephe.Leake@nasa.gov>
Subject: Re: MI ammunition : linked lists
Date: 06 Nov 2003 11:46:11 -0500
Date: 2003-11-06T16:50:07+00:00 [thread overview]
Message-ID: <uad79cung.fsf@nasa.gov> (raw)
In-Reply-To: mailman.293.1068136383.25614.comp.lang.ada@ada-france.org
"amado.alves" <amado.alves@netcabo.pt> writes:
> A very common programming task where multiple inheritance (MI) would
> be handy: implementation of doubly linked lists.
Hmm. I've been using doubly linked lists, and never felt a lack of MI.
> A linked list is a chain of nodes. The first node links to the
> second, the last node links to the penultimate, and each of the
> others nodes links to both the previous and the next. (Each node
> usually also carries a payload, which we can ignore here.)
Ok so far.
> Often (always?) a non OOP design is used with only one type for all
> kinds of nodes, with null values in the unused slots:
>
> ___________ ______ ______ ___________
> | | | | | | | |
> | Prev=null |<-----Prev |<--- ... <-----Prev |<-----Prev |
> | Next---------->| Next-----> ... --->| Next----->| Next=null |
> |___________| |______| |______| |___________|
>
> An OOP design does away with the ugly nulls (however it introduces
> one-of-a-kind objects, which also some people consider ugly):
Why is "null" ugly? It's a perfectly reasonable value.
> ______ ______ ______
> ______ | | | | | |
> | |<-----Prev |<--- ... <-----Prev |<-----Prev |
> | Next----->| Next-----> ... --->| Next----->|______|
> |______| |______| |______|
>
> It is clear that the middle nodes combine the attributes of the first
> and last nodes.
Now the "first" and "last" nodes are of a different type than the
"middle" nodes. When I insert a node, the "last" node changes type!
This is a hammer looking for a nail; I'll just use my screwdriver,
thank you.
--
-- Stephe
next prev parent reply other threads:[~2003-11-06 16:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-06 16:32 MI ammunition : linked lists amado.alves
2003-11-06 16:46 ` Stephen Leake [this message]
2003-11-06 17:15 ` Frank J. Lhota
2003-11-08 10:27 ` Dmitry A. Kazakov
2003-11-06 17:16 ` Jean-Pierre Rosen
2003-11-06 18:15 ` Wes Groleau
2003-11-06 21:03 ` Simon Wright
2003-11-07 10:39 ` Dmitry A. Kazakov
2003-11-07 10:29 ` Dmitry A. Kazakov
2003-11-10 14:51 ` Lutz Donnerhacke
2003-11-10 17:52 ` Marius Amado Alves
2003-11-11 9:32 ` Lutz Donnerhacke
2003-11-11 12:24 ` Marius Amado Alves
2003-11-11 12:58 ` Lutz Donnerhacke
2003-11-11 16:09 ` Robert I. Eachus
2003-11-11 17:11 ` Marius Amado Alves
2003-11-12 9:21 ` Lutz Donnerhacke
-- strict thread matches above, loose matches on Subject: below --
2003-11-06 17:26 amado.alves
2003-11-06 17:33 amado.alves
2003-11-06 19:01 amado.alves
2003-11-11 18:38 ` Georg Bauhaus
2003-11-11 21:27 ` Marius Amado Alves
2003-11-12 0:23 ` Georg Bauhaus
2003-11-12 11:29 amado.alves
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox