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-7-bit X-Google-Thread: 103376,e5327159069b64d5 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Doubly linked list. Date: 1998/12/15 Message-ID: #1/1 X-Deja-AN: 422576860 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <7560vn$21e@romeo.logica.co.uk> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-12-15T00:00:00+00:00 List-Id: Matt Tyler (matt_tyler@hotmail.com) wrote: : I'm having trouble implementing a Doubly linked list in ada. : My procedure to add a new singly linked record to the list is (body only) : List:=new Box'(V,List); : where V is an integer and List is an access type to box. : I don't understand how to set another access type in the record to the : previous record on the list. Can anyone help?? With a doubly linked list, each list element has both a "next" and a "prev" component, in general. You need to initialize both. In general, one will be null in the new element. The following will accomplish the job: -- Insert on front of list List := new Box'(V, Next => List, Prev => null); if List.Next /= null then -- Make old "first" element point back to new "first" List.Next.Prev := List; end if; : P.S is there a comp.lang.ada faq ??????????? Try www.adahome.com. : Cheers, : Matt Tyler -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Intermetrics, Inc. Burlington, MA USA An AverStar Company (www.averstar.com)