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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,b416c884bdec6e56,start X-Google-Attributes: gid103376,public From: J.M. Subject: circularity and symetrical list Date: 1999/09/23 Message-ID: #1/1 X-Deja-AN: 528463395 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: Abuse Role , We Care X-Trace: monger.newsread.com 938049644 205.205.128.174 (Wed, 22 Sep 1999 21:20:44 EDT) Organization: VIF Internet (vif.com) MIME-Version: 1.0 NNTP-Posting-Date: Wed, 22 Sep 1999 21:20:44 EDT Newsgroups: comp.lang.ada Date: 1999-09-23T00:00:00+00:00 List-Id: Does anybody know who i can declare a circularity and symetrical list or anybody can tell me if my structure is good : (sorry my english is very bad ! ) Type Type_Maillon; Type Type_Ptr is access Type_Maillon; Type Type_Maillon is record Info : Type_Element ; Next : Type_Ptr ; Precedent : Type_Ptr ; End record; Procedure Free is new Unchecked_Deallocation (Type_Maillon, Type_Ptr); Procedure Vider (L : in out Type_Ptr) is -- Ant : / -- Cons : clean list Link : Type_Ptr; Begin While L /= null loop Link := L; L.Precedent.Next := L.Next; L.Next.Precedent := L.Precedent; Free (Link); End loop; End Vider; Function Find_Node (L : in Type_Ptr ; i : in Positive) return Type_Ptr is -- Ant�c�dent : / -- Cons�quent : find ptr(i) Indice : Positive; Link : Type_Ptr; Begin -- Find_Node If i <= 0 then Return null; Else Indice := 1; Link := L.Next; While (Indice /= i) and (Link /= L) loop Indice := Indice + 1; Link := Link.Next; End loop; If Indice = i then Return Link; Else Return null; End if; End if; End Find_Node; Procedure Inserer (L : in out Type_Ptr ; Item : in Type_Commande) is -- Ant�c�dent : / -- Cons�quent : insert Item(i) Link1, Link2 : Type_Ptr; Begin -- Inserer Link1 := Find_Node(L,i); If ((i>0) and (Link1 /= Null)) or (i=0) then Link2 := New Type_Maillon; Link2.Info := Item; If i=0 then -- ins�rer en t�te de liste Link2.Next := L.Next; L.Next := Link2; Else Link2.Next := Link1.Next; Link1.Next := Link2; End if; End if; End Inserer;