DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦ec81113b6⟧ TextFile

    Length: 17043 (0x4293)
    Types: TextFile
    Names: »B«

Derivation

└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
    └─ ⟦124ff5788⟧ »DATA« 
        └─⟦this⟧ 
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
    └─ ⟦6f12a12be⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Instancecounter;

separate (Expertsystem)

package body Collection is

    function Defaultname (Aref : Expertsystem.Reference) return Objectname is
        Limage : constant String := Ido'Image (Aref.Idobject);
        Limage2 : Objectname;
    begin
        Limage2 (1 .. Limage'Length) := Limage (1 .. Limage'Length);
        for I in Natural (Limage'Length + 1) .. Natural (Classname'Length) loop
            Limage2 (I) := ' ';
        end loop;
        return (Limage2);
    end Defaultname;

    function Restrict (Thecollection : Collection.Object;
                       Quantity : Natural := Any) return Collection.Object is
        Result : Object (Thecollection.Size);
    begin
        if Thecollection.Count /= 0 then
            for I in 1 .. Thecollection.Count loop
                if Predicate (Thecollection.Cells (I)) then
                    Add (Result, Thecollection.Cells (I));
                    if (Quantity /= Any) and then
                       (Result.Count >= Quantity) then
                        return Result;
                    end if;
                end if;
            end loop;
        end if;
        return Result;
    end Restrict;

    function Findone (Thecollection : Collection.Object)
                     return Expertsystem.Reference is
    begin
        if Thecollection.Count /= 0 then
            for I in 1 .. Thecollection.Count loop
                if Predicate (Thecollection.Cells (I)) then
                    return (Thecollection.Cells (I));
                end if;
            end loop;
        end if;
        return Nullreference;
    end Findone;

    function Notexist (Thecollection : Collection.Object) return Boolean is
    begin
        if Thecollection.Count /= 0 then
            for I in 1 .. Thecollection.Count loop
                if Predicate (Thecollection.Cells (I)) then
                    return (False);
                end if;
            end loop;
        end if;
        return (True);
    end Notexist;

    function Exist (Thecollection : Collection.Object) return Boolean is
    begin
        if Thecollection.Count /= 0 then
            for I in 1 .. Thecollection.Count loop
                if Predicate (Thecollection.Cells (I)) then
                    return (True);
                end if;
            end loop;
        end if;
        return (False);
    end Exist;

    function Themost (Thecollection : Collection.Object)
                     return Expertsystem.Reference is
        Ref : Expertsystem.Reference;
    begin
        if Thecollection.Count = 0 then
            return Nullreference;
        end if;
        Ref := Thecollection.Cells (1);
        for I in 2 .. Thecollection.Count loop
            if not Predicate (Ref, Thecollection.Cells (I)) then
                Ref := Thecollection.Cells (I);
            end if;
        end loop;
        return Ref;
    end Themost;

    function Cardinality (Thecollection : Collection.Object) return Natural is
    begin
        return Thecollection.Count;
    end Cardinality;

    function Isfull (Thecollection : Collection.Object) return Boolean is
    begin
        return Thecollection.Count = Thecollection.Size;
    end Isfull;

    function Isnull (Thecollection : Collection.Object) return Boolean is
    begin
        return Thecollection.Count = 0;
    end Isnull;

    function Isnotnull (Thecollection : Collection.Object) return Boolean is
    begin
        return Thecollection.Count /= 0;
    end Isnotnull;

    function Isnull (Aref : Expertsystem.Reference) return Boolean is
    begin
        return Aref = Nullreference;
    end Isnull;

    function Isnotnull (Aref : Expertsystem.Reference) return Boolean is
    begin
        return Aref /= Nullreference;
    end Isnotnull;

    procedure Add (Thecollection : in out Object;
                   Aref : in Expertsystem.Reference) is
        Alreadyexist : Boolean := False;
    begin
        if (Thecollection.Count /= 0) and then
           (Aref.Idclass /= Thecollection.Cells (1).Idclass) then
            raise Badclass;
        end if;

        if Isfull (Thecollection) then
            declare
                Collection1 : Collection.Object
                                 (Thecollection.Size + Thecollection.Size / 2);
            begin
                Collection1.Cells (1 .. Thecollection.Size) :=
                   Thecollection.Cells (1 .. Thecollection.Size);
                Collection1.Count := Thecollection.Count;
                Collection1.Unity := Thecollection.Unity;
                Thecollection := Collection1;
            end;
        end if;
        for I in 1 .. Thecollection.Count loop
            if Aref.Idobject = Thecollection.Cells (I).Idobject then
                Alreadyexist := True;
            end if;
        end loop;
        if not Alreadyexist then
            Thecollection.Count := Thecollection.Count + 1;
            Thecollection.Cells (Thecollection.Count) := Aref;
        end if;
    end Add;

    procedure Remove (Thecollection : in out Collection.Object;
                      Aref : in Expertsystem.Reference) is
    begin
        if (Thecollection.Count /= 0) and then
           Thecollection.Cells (1).Idclass = Aref.Idclass then
            for I in 1 .. Thecollection.Count loop
                if Thecollection.Cells (I).Idobject = Aref.Idobject then
                    for J in I .. Thecollection.Count - 1 loop
                        Thecollection.Cells (J) := Thecollection.Cells (J + 1);
                    end loop;
                    Thecollection.Count := Thecollection.Count - 1;
                    exit;
                end if;
            end loop;
        end if;
    end Remove;

    procedure Update (Thecollection : in out Collection.Object;
                      Aref : in Expertsystem.Reference) is
    begin
        if (Thecollection.Count /= 0) and then
           Thecollection.Cells (1).Idclass = Aref.Idclass then
            for I in 1 .. Thecollection.Count loop
                if Thecollection.Cells (I).Idobject = Aref.Idobject then
                    Thecollection.Cells (I).Date := Instancecounter.Newobject;
                    exit;
                end if;
            end loop;
        end if;
    end Update;

    procedure Update (Thecollection : in out Collection.Object;
                      Aref : in Expertsystem.Reference;
                      Withdate : in Long_Integer) is
    begin
        if (Thecollection.Count /= 0) and then
           Thecollection.Cells (1).Idclass = Aref.Idclass then
            for I in 1 .. Thecollection.Count loop
                if Thecollection.Cells (I).Idobject = Aref.Idobject then
                    Thecollection.Cells (I).Date := Withdate;
                    exit;
                end if;
            end loop;
        end if;
    end Update;

    procedure Updateall (Thecollection : in out Collection.Object) is
        Adate : Long_Integer;
    begin
        Adate := Instancecounter.Newobject;
        for I in 1 .. Thecollection.Count loop
            Thecollection.Cells (I).Date := Adate;
        end loop;
    end Updateall;

    procedure Clear (Thecollection : in out Collection.Object) is
    begin
        Thecollection.Count := 0;
        Thecollection.Unity := 1;
    end Clear;

    function Union (Collection1 : Collection.Object;
                    Collection2 : Collection.Object) return Collection.Object is
        Result : Collection.Object (Collection1.Size + Collection2.Size);
        Tampon : Collection.Object (Collection2.Size);
    begin
        if Collection1.Count = 0 then
            Result := Collection2;
        elsif Collection2.Count = 0 then
            Result := Collection1;
        else
            if Collection1.Cells (1).Idclass /=
               Collection2.Cells (1).Idclass then
                raise Badclass;
            else
                Tampon := Collection2;
                for I in 1 .. Collection1.Count loop
                    for J in 1 .. Tampon.Count loop
                        if Collection1.Cells (I).Idobject =
                           Tampon.Cells (J).Idobject then
                            Remove (Tampon, Tampon.Cells (J));
                            exit;
                        end if;
                    end loop;
                    Add (Result, Collection1.Cells (I));
                end loop;
                Result.Count := Result.Count + Tampon.Count;
                Result.Cells (1 .. Result.Count + Tampon.Count) :=
                   Result.Cells (1 .. Result.Count) &
                      Tampon.Cells (1 .. Tampon.Count);
            end if;
        end if;
        return Result;
    end Union;

    function Max (Int1, Int2 : Integer) return Integer is
    begin
        if Int1 > Int2 then
            return Int1;
        else
            return Int2;
        end if;
    end Max;

    function Intersection (Collection1 : Collection.Object;
                           Collection2 : Collection.Object)
                          return Collection.Object is
        Result : Collection.Object (Max (Collection1.Size, Collection2.Size));
        Tampon : Collection.Object (Collection2.Size);
    begin
        if (Collection1.Count /= 0) and (Collection2.Count /= 0) then
            if (Collection1.Cells (1).Idclass /=
                Collection2.Cells (1).Idclass) then
                raise Badclass;
            else
                Tampon := Collection2;
                for I in 1 .. Collection1.Count loop
                    for J in 1 .. Tampon.Count loop
                        if Collection1.Cells (I).Idobject =
                           Tampon.Cells (J).Idobject then
                            Remove (Tampon, Tampon.Cells (J));
                            Add (Result, Collection1.Cells (I));
                            exit;
                        end if;
                    end loop;
                end loop;
            end if;
        end if;
        return Result;
    end Intersection;

    function Difference (Collection1 : Collection.Object;
                         Collection2 : Collection.Object)
                        return Collection.Object is
        Result : Collection.Object (Collection1.Size);
    begin
        if Collection2.Count = 0 then
            Result := Collection1;
        elsif (Collection1.Count /= 0) then
            if (Collection1.Cells (1).Idclass /=
                Collection2.Cells (1).Idclass) then
                raise Badclass;
            else
                Result := Collection1;
                for I in 1 .. Collection1.Count loop
                    for J in 1 .. Collection2.Count loop
                        if Collection1.Cells (I).Idobject =
                           Collection2.Cells (J).Idobject then
                            Remove (Result, Collection1.Cells (I));
                            exit;
                        end if;
                    end loop;
                end loop;
            end if;
        end if;
        return Result;
    end Difference;

    function Member (Thecollection : Collection.Object;
                     Aref : Expertsystem.Reference) return Boolean is
        Found : Boolean := False;
    begin
        if Thecollection.Count = 0 then
            Found := False;
        elsif (Aref.Idclass /= Thecollection.Cells (1).Idclass) then
            Found := False;
        else
            for I in 1 .. Thecollection.Count loop
                if Aref.Idobject = Thecollection.Cells (I).Idobject then
                    Found := True;
                    exit;
                end if;
            end loop;
        end if;
        return Found;
    end Member;

    function Isinclude (Collection1 : Collection.Object;
                        Collection2 : Collection.Object) return Boolean is
        Include : Boolean := False;
        Checkcoll : Boolean := False;
    begin
        if Collection1.Count = 0 then
            Include := True;
        elsif (Collection2.Count /= 0) and (Collection1.Cells (1).Idclass =
                                            Collection2.Cells (1).Idclass) then
            Include := True;
            for I in 1 .. Collection1.Count loop
                for J in 1 .. Collection2.Count loop
                    if Collection1.Cells (I).Idobject =
                       Collection2.Cells (J).Idobject then
                        Checkcoll := True;
                        exit;
                    end if;
                end loop;
                if Checkcoll = False then
                    Include := False;
                    exit;
                else
                    Checkcoll := False;
                end if;
            end loop;
        end if;
        return Include;
    end Isinclude;

    function ">" (Collection1 : Collection.Object;
                  Collection2 : Collection.Object) return Boolean is
    begin
        return Isinclude (Collection2, Collection1);
    end ">";


    function Asobject (Aref : Expertsystem.Reference)
                      return Collection.Object is
        Result : Collection.Object;
    begin
        Add (Result, Aref);
        return Result;
    end Asobject;

    function Get (Thecollection : Collection.Object; Number : Positive := 1)
                 return Expertsystem.Reference is
    begin
        if Number > Thecollection.Count then
            return Nullreference;
        else
            return Thecollection.Cells (Number);
        end if;
    end Get;

    function First (Thecollection : Collection.Object)
                   return Expertsystem.Reference is
    begin
        return Get (Thecollection, 1);
    end First;

    function Rest (Thecollection : Collection.Object)
                  return Collection.Object is
        Acollection : Collection.Object;
    begin
        Acollection := Thecollection;
        Collection.Remove (Acollection, Get (Thecollection, 1));
        return (Acollection);
    end Rest;

    function Get (Thecollection : Collection.Object;
                  Frompos : Positive := 1;
                  Topos : Positive) return Collection.Object is
        Result : Collection.Object;
        Bornefrom : Natural;
        Borneto : Natural;
    begin
        if Topos > Thecollection.Count then
            Borneto := Thecollection.Count;
        else
            Borneto := Topos;
        end if;
        if Frompos < Thecollection.Cells'First then
            Bornefrom := Thecollection.Cells'First;
        else
            Bornefrom := Frompos;
        end if;

        for I in Bornefrom .. Borneto loop
            Add (Result, Get (Thecollection, I));
        end loop;
        return Result;
    end Get;

    procedure Forall (Thecollection : Collection.Object) is
    begin
        for I in 1 .. Thecollection.Count loop
            Action (Get (Thecollection, I));
        end loop;
    end Forall;

    procedure Sort (Thecollection : in out Collection.Object) is
        Repere : Integer range Thecollection.Cells'First - 1 ..
                                  Thecollection.Cells'Last;
        Nombre : Expertsystem.Reference;
    begin
        for I in Thecollection.Cells'First + 1 .. Thecollection.Count - 1 loop
            Nombre := Thecollection.Cells (I);
            Repere := I - 1;
            while (Repere /= Thecollection.Cells'First - 1) and then
                     (Nombre < Thecollection.Cells (Repere)) loop
                Thecollection.Cells (Repere + 1).Idclass :=
                   Thecollection.Cells (Repere).Idclass;
                Repere := Repere - 1;
            end loop;
            Thecollection.Cells (Repere + 1) := Nombre;
        end loop;
    end Sort;

    package body Iterator is
        function Open (Thecollection : Collection.Object) return Iter is
        begin
            if Thecollection.Count = 0 then
                return 0;
            else
                return 1;
            end if;
        end Open;

        function Get (Thecollection : Collection.Object; I : Iter)
                     return Expertsystem.Reference is
            Idx : Integer;
        begin
            Idx := Integer (I);
            if Idx > Thecollection.Count then
                raise Illegalaccess;
            end if;
            return Thecollection.Cells (Idx);
        exception
            when Constraint_Error =>
                raise Illegalaccess;
        end Get;

        function Next (Thecollection : Collection.Object; I : Iter)
                      return Iter is
            Idx : Integer;
        begin
            Idx := Integer (I) + 1;
            if Idx > Thecollection.Count then
                return 0;
            else
                return Iter (Idx);
            end if;
        exception
            when Constraint_Error =>
                raise Illegalaccess;
        end Next;

        function Atend (Thecollection : Collection.Object; I : Iter)
                       return Boolean is
        begin
            return I = 0;
        end Atend;
    end Iterator;

end Collection;