comp.lang.ada
 help / color / mirror / Atom feed
* circularity and symetrical list
@ 1999-09-23  0:00 J.M.
  1999-09-23  0:00 ` Robert Dewar
  1999-09-23  0:00 ` tmoran
  0 siblings, 2 replies; 3+ messages in thread
From: J.M. @ 1999-09-23  0:00 UTC (permalink / 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;






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: circularity and symetrical list
  1999-09-23  0:00 circularity and symetrical list J.M.
@ 1999-09-23  0:00 ` Robert Dewar
  1999-09-23  0:00 ` tmoran
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1999-09-23  0:00 UTC (permalink / raw)


In article <TI7pN3ljFpOxpTEKBinVmVSYyk6X@4ax.com>,
  J.M. <j_m_1@hotmail.com> wrote:
> 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 ! )


Generally I don't think you can expect CLA to act as a debugger
for your program, especially if, as is likely, this is a
homework assignment. What you need to do is to compile and
run the program, and then if necessary learn how to use the
debugger to debug it. If you get error messages you don't
understand at compile time, or you narrow down your runtime
problems to a very specific problem that you don't understand,
then is the time to ask for help on CLA


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: circularity and symetrical list
  1999-09-23  0:00 circularity and symetrical list J.M.
  1999-09-23  0:00 ` Robert Dewar
@ 1999-09-23  0:00 ` tmoran
  1 sibling, 0 replies; 3+ messages in thread
From: tmoran @ 1999-09-23  0:00 UTC (permalink / 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
  First, let the compiler help you out.  Your code as given won't
compile, and the compiler's error message will point to the problem.
  Second, once the package compiles, try running a test program
using it.  It will soon become obvious there's a problem.  It
should be clear where the problem lies, and on looking carefully
at your code you will say "How could I have done that!".
  While somewhat over-complicated, your code is on the right track.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-09-23  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-23  0:00 circularity and symetrical list J.M.
1999-09-23  0:00 ` Robert Dewar
1999-09-23  0:00 ` tmoran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox