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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,955f3216aaa64cc0 X-Google-Attributes: gid103376,public From: Ricardo Palomares =?iso-8859-1?Q?Mart=EDnez?= Subject: Re: Doubly linked list (again, sorry) Date: 1998/12/16 Message-ID: <3677A69C.C197C703@eucmax.sim.ucm.es>#1/1 X-Deja-AN: 422851770 Content-Transfer-Encoding: quoted-printable References: <7580p3$q00@romeo.logica.co.uk> To: Matt Tyler X-Accept-Language: es,en Content-Type: text/plain; charset=iso-8859-1 Organization: Univ. Complutense de Madrid Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-16T00:00:00+00:00 List-Id: Matt Tyler wrote: > Hello. > > I have created a doubly linked list. With the procedure (body only) > > List:=3Dnew cell'(V,Next=3D>, Prev=3D>null); > > (...) > > > To loop from start of list do I need to create a (say) Start_of_list ac= cess > type to the first cell in the list or is there a more elegant way that = I am > missing. You should have a pointer to the first element of the list and other = to the last one. You also need another pointer to the current element when walki= ng through the list. > Also, when I remove (to delete) a record from the list do I have to > de-allocate the memory occupied by the object or is it done for me. You need to de-allocate it. I can't recall it right, but it has to do= with Unchecked_Deallocation package or similar. Anyway, read the end of my mes= sage. > I am sorry to waste your time but I am having a few problems with acces= s > types. Thanks in advance You seem to have some lack of knowledge about the basics of the double-linked lists, rather than implementing it in Ada. Perhaps you may = wish to give a look to some data structure or programming books (Knuth: "Data str= uctures + Algorithms =3D Programs" IIRC, or Schultz: "Data Structures"; there is = a long time since I had my hands over these books and the title may be inaccurat= e). Anyway, the newsgroups are to help us each other. About the double-linked list, I wrote a generic package to implement double-linked list with n indexes (ie, n different pairs of pathways to r= un through the list; think of every element as a link of a chain: then, ever= y index lets you put the links in a different order to form the chain). The gener= ic package lets you use any data type. It is not really a fast implementatio= n, because due to the nature of the package, you can't access directly to th= e pointer type; instead, you have an identifier to which you refer always y= ou need to access a specific element, and internally to the package the list is w= alked until the element is found. So, if you have big trouble implementing a double-linked list I can s= end the code to you (the identifiers and comments are in spanish, but I can trans= late the more important things if you want). HTH -- Ricardo Palomares Mart=EDnez -------- mailto:ricardo@eucmax.sim.ucm.es UCM - Servicio Inform=E1tico Gesti=F3n -- http://www.ucm.es/info/gstwsig