|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 8192 (0x2000) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Generic_Binary_Tree, seg_04750d
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─⟦5a81ac88f⟧ »Space Info Vol 1« └─⟦this⟧
package body Generic_Binary_Tree is procedure Purge (The_Tree : in out Object) is begin The_Tree := null; end Purge; function Is_Empty (The_Tree : in Object) return Boolean is begin return (The_Tree = null); end Is_Empty; function Consult (The_Tree : in Object) return Element is begin return The_Tree.Content; end Consult; procedure Insert (The_Tree : in out Object; What : Element) is begin if (Is_Empty (The_Tree) = True) then The_Tree := new Node'(Content => What, Left => null, Right => null); else if (Are_Equal (Consult (The_Tree), What)) then raise Value_Already_Exists; end if; if (What < Consult (The_Tree)) then Insert (The_Tree.Left, What); else Insert (The_Tree.Right, What); end if; end if; end Insert; procedure Get_Value (The_Tree : in Object; What : in out Element) is begin if not Is_Empty (The_Tree) then if (Are_Equal (Consult (The_Tree), What)) then What := Consult (The_Tree); else if (What < Consult (The_Tree)) then Get_Value (The_Tree.Left, What); else Get_Value (The_Tree.Right, What); end if; end if; else raise Value_Does_Not_Exist; end if; end Get_Value; procedure Update (The_Tree : in Object; What : in Element) is begin if not Is_Empty (The_Tree) then if (Are_Equal (Consult (The_Tree), What)) then The_Tree.Content := What; else if (What < Consult (The_Tree)) then Update (The_Tree.Left, What); else Update (The_Tree.Right, What); end if; end if; else raise Value_Does_Not_Exist; end if; end Update; function Exists (The_Tree : in Object; What : in Element) return Boolean is begin if not Is_Empty (The_Tree) then if (Are_Equal (Consult (The_Tree), What)) then return True; else if (What < Consult (The_Tree)) then return Exists (The_Tree.Left, What); else return Exists (The_Tree.Right, What); end if; end if; else return False; end if; end Exists; procedure Light_Copy (Source : in Object; Target : in out Object) is begin Target := Source; end Light_Copy; procedure Deep_Copy (Source : in Object; Target : in out Object) is begin if not Is_Empty (Source) then Target := new Node; Deep_Copy (Source.Content, Target.Content); Deep_Copy (Source.Left, Target.Left); Deep_Copy (Source.Right, Target.Right); end if; end Deep_Copy; -- gestion de l'iterateur procedure Open (It : in out Iterator; The_Tree : Object) is begin It.Current := The_Tree; It.Is_Opened := True; if not (Stack.Is_Empty (It.The_Stack)) then Stack.Dispose (It.The_Stack); end if; Stack.Push (It.The_Stack, It.Current); while ((It.Current.Left) /= null) loop It.Current := It.Current.Left; Stack.Push (It.The_Stack, It.Current); end loop; end Open; procedure Next (It : in out Iterator) is Parent : Object; Stop : Boolean := False; begin if not (It.Is_Opened) then raise Iterator_Is_Not_Opened; end if; if ((It.Current.Right) /= null) then It.Current := It.Current.Right; Stack.Push (It.The_Stack, It.Current); while ((It.Current.Left) /= null) loop It.Current := It.Current.Left; Stack.Push (It.The_Stack, It.Current); end loop; else Stack.Pop (It.The_Stack); while ((Stack.Is_Empty (It.The_Stack) = False) and (Stop = False)) loop Parent := Stack.Consult (It.The_Stack); if (It.Current /= (Parent.Right)) then Stop := True; else Stack.Pop (It.The_Stack); end if; It.Current := Parent; end loop; end if; end Next; function At_End (It : in Iterator) return Boolean is begin if not (It.Is_Opened) then raise Iterator_Is_Not_Opened; end if; return Stack.Is_Empty (It.The_Stack); end At_End; function Consult (It : Iterator) return Element is begin if not (It.Is_Opened) then raise Iterator_Is_Not_Opened; end if; return (It.Current.Content); end Consult; end Generic_Binary_Tree;
nblk1=7 nid=0 hdr6=e [0x00] rec0=23 rec1=00 rec2=01 rec3=014 [0x01] rec0=1b rec1=00 rec2=02 rec3=006 [0x02] rec0=21 rec1=00 rec2=03 rec3=03e [0x03] rec0=0a rec1=00 rec2=07 rec3=006 [0x04] rec0=1b rec1=00 rec2=05 rec3=068 [0x05] rec0=22 rec1=00 rec2=04 rec3=008 [0x06] rec0=02 rec1=00 rec2=06 rec3=000 tail 0x215444c02865393347bbd 0x42a00088462060003