From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ecfc0548c2df0d76 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-06 08:47:07 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!ihug.co.nz!logbridge.uoregon.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: MI ammunition : linked lists Date: 06 Nov 2003 11:46:11 -0500 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: shevek.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1068137407 26676 128.183.235.101 (6 Nov 2003 16:50:07 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 6 Nov 2003 16:50:07 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.ada:2153 Date: 2003-11-06T16:50:07+00:00 List-Id: "amado.alves" 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