|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 3625 (0xe29)
Types: TextFile
Names: »B«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
package body Singly_Linked_List_Generic is
function Create return List is
--
The_List : List;
--
begin
return (The_List);
end Create;
function Copy (Of_List : in List) return List is
--
Original_List : List := Of_List;
--
New_List : List := Create;
--
begin
Reset (Original_List);
while (not Done (Original_List)) loop
Add (New_List, Copy (Current (Original_List)));
Next (Original_List);
end loop;
Reset (Original_List);
Reset (New_List);
return (New_List);
end Copy;
procedure Add (To_List : in out List;
This_Element : in Element) is
--
New_Node : Pointer := new Node'(Contents => This_Element,
Next => null);
--
begin
if (Is_Empty (To_List)) then
To_List.First := New_Node;
To_List.Last := New_Node;
else
To_List.Last.Next := New_Node;
To_List.Last := New_Node;
end if;
To_List.Count := To_List.Count + 1;
To_List.Position := To_List.Count;
To_List.Current := New_Node;
end Add;
function Done (This_List : in List) return Boolean is
begin
return (This_List.Current = null);
end Done;
procedure Reset (This_List : in out List) is
begin
This_List.Current := This_List.First;
if (Done (This_List)) then
This_List.Position := 0;
else
This_List.Position := 1;
end if;
end Reset;
function Current (This_List : in List) return Element is
begin
return (This_List.Current.Contents);
exception
when others =>
raise No_Current_Element;
end Current;
procedure Modify (This_List : in out List; New_Element : in Element) is
begin
This_List.Current.Contents := New_Element;
exception
when others =>
raise No_Current_Element;
end Modify;
procedure Next (This_List : in out List) is
begin
This_List.Current := This_List.Current.Next;
This_List.Position := This_List.Position + 1;
exception
when others =>
raise No_Next_Element;
end Next;
function Position (In_List : in List) return Element_Number is
begin
if (Done (In_List)) then
raise No_Current_Element;
end if;
return (In_List.Position);
end Position;
procedure Set (This_List : in out List; To_Element : in Element_Number) is
begin
Reset (This_List);
for Counter in 1 .. (To_Element - 1) loop
Next (This_List);
end loop;
exception
when others =>
raise Out_Of_Range;
end Set;
function Element_At (This_Position : in Element_Number; In_List : in List)
return Element is
--
Current : Pointer := In_List.First;
--
begin
for Counter in 1 .. (This_Position - 1) loop
Current := Current.Next;
end loop;
return (Current.Contents);
exception
when others =>
raise Out_Of_Range;
end Element_At;
function Is_Empty (This_List : in List) return Boolean is
begin
return (Elements_In (This_List) = 0);
end Is_Empty;
function Elements_In (This_List : in List) return Natural is
begin
return (This_List.Count);
end Elements_In;
end Singly_Linked_List_Generic;