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=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable 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-10 09:53:04 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!skynet.be!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Marius Amado Alves Newsgroups: comp.lang.ada Subject: Re: MI ammunition : linked lists Date: Mon, 10 Nov 2003 17:52:33 +0000 Organization: Cuivre, Argent, Or Message-ID: References: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1068486782 45607 80.67.180.195 (10 Nov 2003 17:53:02 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Mon, 10 Nov 2003 17:53:02 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: X-Mailer: Ximian Evolution 1.4.5 X-OriginalArrivalTime: 10 Nov 2003 17:52:13.0838 (UTC) FILETIME=[5F6BA2E0:01C3A7B3] X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:2309 Date: 2003-11-10T17:52:33+00:00 On Mon, 2003-11-10 at 14:51, Lutz Donnerhacke wrote: > * amado.alves wrote: > > A very common programming task where multiple inheritance (MI) would be > > handy: implementation of doubly linked lists. > > Single instantiated doubly linked lists. > > Usually I need nodes which are member in multiple lists or trees. That's why > I prefer a mixin design which allows me to specify the required list the > node is member of directly. > > Please clarify how you approach deal with multiple membership. I think you mean you need your "data" (payload, cargo, element...) to participate in different structures. Not strictly the "node". I was discussing only the structural relations of nodes (next, prev). There are a number of ways to attach data to a node. If the data must be shared between different structures a straightforward way is to have the node type have a component that points to the (logical) data. _______ _______ | | | | _______ | Next ----->| Next------>| | | |<-----Prev |<-----Prev | (List 1) | Datum | | | | | |___|___| | Datum | | Datum | | |___|___| |___|___| | | | _\|/_ _\|/_ _\|/_ | | | | | | (Data) |_____| |_____| |_____| /|\ /|\ /|\ ___|___ ___|___ | | | | | | | ___|___ | Datum | | Datum | | | | | | | | | Datum | (List 2) | Next ----->| Next------>| | |_______|<-----Prev |<-----Prev | |_______| |_______| Note I have already conceded that polymorphism for lists in Ada is troublesome because your need to change the type of certain nodes upon certain update operations to the list (and in Ada you cannot change the type of an object). I do not think polymorphism poses a problem with respect to sharing data.