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: ┃ T

⟦f90c610bb⟧ TextFile

    Length: 18105 (0x46b9)
    Types: TextFile
    Names: »TUPLECOLL_ADA«

Derivation

└─⟦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

separate(expertSystem)

package body tupleCollection is

   function getRef(c : collection.object; 
	    number : positive := 1) 
   return   expertSystem.reference 
   renames  collection.get;

   function card(c : collection.object)
   return   natural 
   renames  collection.cardinality;

   function get(theTupleCollection : tupleCollection.object;
	        number             : positive :=1) 
   return   expertSystem.reference is
   begin
      if number > theTupleCollection.count then
	 return nullReference;
      else
	 return theTupleCollection.cells(number);
      end if;
   end get;

   function isFull(theTupleCollection : tupleCollection.object) return boolean is
   begin
      return theTupleCollection.count >= theTupleCollection.size;
   end isFull;

   procedure add(theTupleCollection : in out tupleCollection.object; 
		 aRef               : expertSystem.reference) is
   begin
      if isFull(theTupleCollection) then
	 declare
	    bigTupleColl: tupleCollection.object(theTupleCollection.size + 
						 theTupleCollection.size/2);
	 begin
	    bigTupleColl.cells(1..theTupleCollection.size)
			       := theTupleCollection.cells(1..theTupleCollection.size);
	    bigTupleColl.count := theTupleCollection.count;
	    bigTupleColl.unity := theTupleCollection.unity;
	    theTupleCollection := bigTupleColl;
	 end;
      end if;
      theTupleCollection.count := theTupleCollection.count + 1;
      theTupleCollection.cells (theTupleCollection.count) := aRef;	
   end add;

   procedure merge(theTupleCollection : in out tupleCollection.object;
		   r1       : expertSystem.reference := nullReference;
   		   r2       : expertSystem.reference := nullReference;
   		   r3       : expertSystem.reference := nullReference;
   		   r4       : expertSystem.reference := nullReference;
   		   r5       : expertSystem.reference := nullReference;
   		   r6       : expertSystem.reference := nullReference;
   		   r7       : expertSystem.reference := nullReference;
   		   r8       : expertSystem.reference := nullReference;
   		   r9       : expertSystem.reference := nullReference;
   		   r10      : expertSystem.reference := nullReference) is
   begin
       if r1 /= nullReference then
	  add(theTupleCollection, r1);
       end if;
       if r2 /= nullReference then
	  add(theTupleCollection, r2);
       end if;
       if r3 /= nullReference then
	  add(theTupleCollection, r3);
       end if;
       if r4 /= nullReference then
	  add(theTupleCollection, r4);
       end if;
       if r4 /= nullReference then
	  add(theTupleCollection, r4);
       end if;
       if r5 /= nullReference then
	  add(theTupleCollection, r5);
       end if;
       if r6 /= nullReference then
	  add(theTupleCollection, r6);
       end if;
       if r7 /= nullReference then
	  add(theTupleCollection, r7);
       end if;
       if r8 /= nullReference then
	  add(theTupleCollection, r8);
       end if;
       if r9 /= nullReference then
	  add(theTupleCollection, r9);
       end if;
       if r10 /= nullReference then
	  add(theTupleCollection, r10);
       end if;

   end merge;

   function cardinality(theTupleCollection : tupleCollection.object) return natural is
   begin
      return theTupleCollection.count/theTupleCollection.unity;
   end cardinality;

   function isNull(theTupleCollection : tupleCollection.object) return boolean is
   begin
      return theTupleCollection.count = 0;
   end isNull;

   function isNotNull(theTupleCollection : tupleCollection.object) return boolean is
   begin
      return theTupleCollection.count /= 0;
   end isNotNull;

   function join1(c1 : collection.object; quantity : natural := 1) 
   return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 1;
      for i in 1..card(c1) loop
         r1 := getRef(c1,i);
         if match(r1) then
	   merge(theTupleCollection,r1);
	   if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
              return theTupleCollection;
	   end if;
	end if;
      end loop;
      return theTupleCollection;
   end join1;

   function join2(c1, c2 : collection.object; quantity : natural := 1) 
   return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 2;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
        r2 := getRef(c2,j);
        if match(r1,r2) then
	   merge(theTupleCollection,r1,r2);
	   if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
              return theTupleCollection;
	   end if;
	end if;
       end loop;
      end loop;
      return theTupleCollection;
   end join2;

   function join3(c1, c2, c3 : collection.object; quantity : natural := 1)
   return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 3;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
        r2 := getRef(c2,j);
        for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 if match(r1,r2,r3) then
	    merge(theTupleCollection,r1,r2,r3);
	    if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
	       return theTupleCollection;
	    end if;
	 end if;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join3;

   function join4(c1, c2, c3, c4 : collection.object; quantity : natural := 1)
   return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 4;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
        r2 := getRef(c2,j);
        for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  if match(r1,r2,r3,r4) then
	     merge(theTupleCollection,r1,r2,r3,r4);
	     if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
                return theTupleCollection;
	     end if;
	  end if;
         end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join4;

   function join5(c1, c2, c3, c4, c5 : collection.object;
		  quantity : natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 5;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
	r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   if match(r1,r2,r3,r4,r5) then
	      merge(theTupleCollection,r1,r2,r3,r4,r5);
	      if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
                 return theTupleCollection;
	      end if;
	   end if;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join5;

   function join6(c1, c2, c3, c4, c5, c6 : collection.object; 
   	          quantity : natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5,r6 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 6;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
	r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   for n in 1..card(c6) loop
	    r6 := getRef(c6,n);
	    if match(r1,r2,r3,r4,r5,r6) then
	       merge(theTupleCollection,r1,r2,r3,r4,r5,r6);
	       if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
                  return theTupleCollection;
	       end if;
	    end if;
	   end loop;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join6;

   function join7(c1, c2, c3, c4, c5, c6, c7 : collection.object; 
		  quantity: natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5,r6,r7 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 7;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
	r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   for n in 1..card(c6) loop
	    r6 := getRef(c6,n);
	    for p in 1..card(c7) loop
	     r7 := getRef(c7,p);
	     if match(r1,r2,r3,r4,r5,r6,r7) then
	        merge(theTupleCollection,r1,r2,r3,r4,r5,r6,r7);
	        if (quantity /= ANY) and then (theTupleCollection.count/theTupleCollection.unity >= quantity) then
   	           return theTupleCollection;
	        end if;
	     end if;
	    end loop;
	   end loop;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join7;

   function join8(c1, c2, c3, c4, c5, c6, c7, c8 : collection.object; 
		  quantity: natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5,r6,r7,r8 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 8;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
	r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   for n in 1..card(c6) loop
	    r6 := getRef(c6,n);
	    for p in 1..card(c7) loop
	     r7 := getRef(c7,p);
	     for q in 1..card(c8) loop
	      r8 := getRef(c8,q);
	      if match(r1,r2,r3,r4,r5,r6,r7,r8) then
	         merge(theTupleCollection,r1,r2,r3,r4,r5,r6,r7,r8);
	         if (quantity /= ANY) and then
	            (theTupleCollection.count/theTupleCollection.unity >= quantity) then
		    return theTupleCollection;
	         end if;
	      end if;
	     end loop;
	    end loop;
	   end loop;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join8;

   function join9(c1, c2, c3, c4, c5, c6, c7, c8, c9 : collection.object; 
		  quantity: natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5,r6,r7,r8,r9 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 9;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
        r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   for n in 1..card(c6) loop
	    r6 := getRef(c6,n);
	    for p in 1..card(c7) loop
	     r7 := getRef(c7,p);
	     for q in 1..card(c8) loop
	      r8 := getRef(c8,q);
	      for r in 1..card(c9) loop
	       r9 := getRef(c9,r);
	       if match(r1,r2,r3,r4,r5,r6,r7,r8,r9) then
	          merge(theTupleCollection,r1,r2,r3,r4,r5,r6,r7,r8,r9);
	          if (quantity /= ANY) and then
	             (theTupleCollection.count/theTupleCollection.unity >= quantity) then
	             return theTupleCollection;
	          end if;
	       end if;
	      end loop;
	     end loop;
	    end loop;
	   end loop;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join9;

   function join10(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 : collection.object; 
	           quantity: natural := 1) return tupleCollection.object is
      theTupleCollection : tupleCollection.object;
      r1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : expertSystem.reference;
   begin
      theTupleCollection.count := 0;
      theTupleCollection.unity := 10;
      for i in 1..card(c1) loop
       r1 := getRef(c1,i);
       for j in 1..card(c2) loop
        r2 := getRef(c2,j);
	for k in 1..card(c3) loop
	 r3 := getRef(c3,k);
	 for l in 1..card(c4) loop
	  r4 := getRef(c4,l);
	  for m in 1..card(c5) loop
	   r5 := getRef(c5,m);
	   for n in 1..card(c6) loop
	    r6 := getRef(c6,n);
	    for p in 1..card(c7) loop
	     r7 := getRef(c7,p);
	     for q in 1..card(c8) loop
	      r8 := getRef(c8,q);
	      for r in 1..card(c9) loop
	       r9 := getRef(c9,r);
	       for s in 1..card(c10) loop
	        r10 := getRef(c10,s);
	        if match(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10) then
	           merge(theTupleCollection,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10);
	  	   if (quantity /= ANY) and then
		      (theTupleCollection.count/theTupleCollection.unity >= quantity) then
		      return theTupleCollection;
		   end if;
	        end if;
	       end loop;
	      end loop;
	     end loop;
	    end loop;
	   end loop;
	  end loop;
	 end loop;
	end loop;
       end loop;
      end loop;
      return theTupleCollection;
   end join10;

   function theMost(theTupleCollection : object) return tuple.object is
      tu, ti : tuple.object;
   begin
      if theTupleCollection.count /= 0 then
         tu := first(theTupleCollection);
         for i in 2..theTupleCollection.count/theTupleCollection.unity loop
   	    ti := get(theTupleCollection, i);
	    if not predicate(tu, ti) then
	       tu := ti;
	    end if;
         end loop;
      end if;
      return tu;
   end theMost;

   function restrict(theTupleCollection : tupleCollection.object; 
quantity : natural := ANY) return tupleCollection.object is
      result : tupleCollection.object;
      ti     : tuple.object;
   begin
      if theTupleCollection.count /= 0 then
	 result.unity := theTupleCollection.unity;
	 for i in 1..theTupleCollection.count/theTupleCollection.unity loop
	    ti := get(theTupleCollection, i);
	    if predicate(ti) then
	       for j in 1..theTupleCollection.unity loop
		  add(result,tuple.get(ti,j));
	       end loop;
	       if (quantity /= ANY) and then
		  (result.count/result.unity>=quantity) then
		  return result;
	       end if;
	    end if;
	 end loop;
      end if;
      return result;
   end restrict;

   function findOne(theTupleCollection : tupleCollection.object) return tuple.object is
      t : tuple.object;
   begin
      if theTupleCollection.count /= 0 then
	 for i in 1..theTupleCollection.count/theTupleCollection.unity loop
	    t := get(theTupleCollection, i);
	    if predicate(t) then
	       return t;
	    end if;
	 end loop;
      end if;
      return t;
   end findOne;

   function get(theTupleCollection : tupleCollection.object ;
 number : positive := 1) return tuple.object is
      tu : tuple.object;
   begin
      if number <= theTupleCollection.count/theTupleCollection.unity then
	 for i in 1..theTupleCollection.unity loop
	    tuple.add(tu,get(theTupleCollection,(number-1)*theTupleCollection.unity + i));
	 end loop;
      end if;
      return tu;
   end get;

   function first(theTupleCollection : tupleCollection.object) return tuple.object is
   begin
      return get(theTupleCollection,1);
   end first;

   function get     (theTupleCollection : tupleCollection.object;
		     fromPos            : positive :=1;
		     toPos              : positive)    
   return tupleCollection.object is
      tuc   : tupleCollection.object;
      borneFrom : natural;
      borneTo   : natural;
   begin
      if toPos   >  theTupleCollection.count/theTupleCollection.unity then
	 borneTo := theTupleCollection.count/theTupleCollection.unity;
      else
	 borneTo := toPos;
      end if;
      if fromPos   <  theTupleCollection.cells'FIRST then
	 borneFrom := theTupleCollection.cells'FIRST;
      else 
	 borneFrom := fromPos;
      end if;

      tuc.unity := theTupleCollection.unity;
      for i in borneFrom..theTupleCollection.unity*borneTo loop
	 add(tuc, get(theTupleCollection,i));
      end loop;
      return tuc;
   end get;

   procedure forAll(theTupleCollection : tupleCollection.object) is
   begin
      for i in 1..theTupleCollection.count/theTupleCollection.unity loop
	 declare
            tu : tuple.object;
	 begin
	    for j in 1..theTupleCollection.unity loop
  	       tuple.add(tu,get(theTupleCollection,(i-1)*
				theTupleCollection.unity + j ));
            end loop;
            action(tu);
         end;
      end loop;
   end forAll;


   package body iterator is
      function open(theTupleCollection : tupleCollection.object) return iter is
      begin
	 if theTupleCollection.count = 0 then
	    return 0;
	 else
	    return 1;
	 end if;
      end open;

      function get(theTupleCollection : tupleCollection.object; i : iter) return tuple.object is
      begin
	 if i > iter(theTupleCollection.count/theTupleCollection.unity)  then
	    raise illegalAccess;
	 end if;
	 return get(theTupleCollection,positive(i));
	 exception
	    when CONSTRAINT_ERROR => raise illegalAccess;
      end get;

      function next(theTupleCollection : tupleCollection.object; i : iter) return iter is
	 idx : integer;
      begin
	 idx := INTEGER(i) + 1;
	 if idx > theTupleCollection.count/theTupleCollection.unity then
	    return 0;
	 else
	    return iter(idx);
	 end if;
	 exception
	    when CONSTRAINT_ERROR => raise illegalAccess;
      end next;

      function atEnd(theTupleCollection : tupleCollection.object; i : iter) return boolean is
      begin
	 return i = 0;
      end atEnd;
   end iterator;

end tupleCollection;