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-11 01:32:13 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.vmunix.org!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: MI ammunition : linked lists Date: Tue, 11 Nov 2003 09:32:12 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1068543132 10162 217.17.192.37 (11 Nov 2003 09:32:12 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Tue, 11 Nov 2003 09:32:12 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:2328 Date: 2003-11-11T09:32:12+00:00 List-Id: * Marius Amado Alves wrote: > On Mon, 2003-11-10 at 14:51, Lutz Donnerhacke wrote: >> 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". Yep. > 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. I do not like access types. They provide additional error sources. > _______ _______ >| | | | _______ >| Next ----->| Next------>| | >| |<-----Prev |<-----Prev | (List 1) >| Datum | | | | | >|___|___| | Datum | | Datum | > | |___|___| |___|___| > | | | > _\|/_ _\|/_ _\|/_ > | | | | | | (Data) > |_____| |_____| |_____| > /|\ /|\ /|\ > ___|___ ___|___ | >| | | | | | ___|___ >| Datum | | Datum | | | | >| | | | | Datum | (List 2) >| Next ----->| Next------>| | >|_______|<-----Prev |<-----Prev | > |_______| |_______| My structure looks like the following: Datum Node1 <- List1 Node2 <- List2 -------------------- type Base is limited tagged record d : Datum; end record; package Base_List1 is new Double_Linked_List (Base); use Base_List1; package Base_List2 is new Double_Linked_List (List1); use Base_List2; type Node is new Base_List2.Object; list1 : Base_List1.List; list2 : Base_List2.List; -------------------- Choosing the right part of the data structure is done by static polymorphism at compile time.