From: J.M. <j_m_1@hotmail.com>
Subject: circularity and symetrical list
Date: 1999/09/23
Date: 1999-09-23T00:00:00+00:00 [thread overview]
Message-ID: <TI7pN3ljFpOxpTEKBinVmVSYyk6X@4ax.com> (raw)
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;
next reply other threads:[~1999-09-23 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-23 0:00 J.M. [this message]
1999-09-23 0:00 ` circularity and symetrical list tmoran
1999-09-23 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox