Changeset ffb732 in git for factory


Ignore:
Timestamp:
Aug 26, 2014, 12:17:46 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
d1a30265ddb8a7ddc9d68bb7a60e37212c7f06b0
Parents:
8b7b108474a7f7dcc5bffc2636ab9027c6131d3d
git-author:
Martin Lee <martinlee84@web.de>2014-08-26 12:17:46+02:00
git-committer:
Martin Lee <martinlee84@web.de>2014-08-26 12:29:12+02:00
Message:
replaced isSame, isMember, MyUnion, minus by new templates
Location:
factory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • factory/cfCharSets.cc

    r8b7b108 rffb732  
    437437    l= tmp.getFirst();
    438438
    439     tmp= minus (tmp, l);
     439    tmp= Difference (tmp, l, operator==);
    440440
    441441    select (ppi, l.length(), ppi1, ppi2);
     
    444444
    445445    if (count > 0)
    446       ppi= MyUnion (ListCFList (l), ppi1);
     446      ppi= Union (ppi1, ListCFList (l), operator==);
    447447    else
    448448      ppi= ListCFList();
     
    455455    if (charset.length() > 0 && charset.getFirst().level() > 0)
    456456    {
    457       result= MyUnion (result, ListCFList (charset));
     457      result= Union (ListCFList (charset), result, operator==);
    458458      ini= factorsOfInitials (charset);
    459459
     
    468468
    469469    tmp2= adjoin (ini, l, qqi);
    470     tmp= MyUnion (tmp, tmp2);
     470    tmp= Union (tmp2, tmp, operator==);
    471471
    472472    StoredFactors.FS1= CFList();
     
    616616    {
    617617      nr_of_iteration += 1;
    618       ppi= MyUnion (ListCFList (qs), ppi1);
     618      ppi= Union (ppi1, ListCFList (qs), operator==);
    619619    }
    620620
     
    636636        if (!isSubset (cs,qs))
    637637          cs= charSetViaCharSetN (Union (qs,cs));
    638         if (!isMember (cs, pi))
     638        if (!find (pi, cs, operator==))
    639639        {
    640           pi= MyUnion (pi, ListCFList (cs));
     640          pi= Union (ListCFList (cs), pi, operator==);
    641641          if (cs.getFirst().level() > 0)
    642642          {
     
    645645            if (indexRed <= 0) //irreducible
    646646            {
    647               qsi= MyUnion (qsi, ListCFList(cs));
     647              qsi= Union (ListCFList(cs), qsi, operator==);
    648648              if (cs.length() == highestlevel)
    649649                is= factorPSet (factorset);
     
    674674          }
    675675          is= Union (factorsOfInitials (cst), is);
    676           iss= MyUnion (adjoin (is, qs, qqi), adjoinb (ts, qs, qqi, cst));
     676          iss= Union (adjoinb (ts, qs, qqi, cst), adjoin (is, qs, qqi), operator==);
    677677        }
    678678        else
     
    685685    {
    686686      qhi.removeFirst();
    687       qhi= MyUnion (qhi, iss);
     687      qhi= Union (iss, qhi, operator==);
    688688    }
    689689    else
  • factory/cfCharSetsUtil.cc

    r8b7b108 rffb732  
    457457
    458458/* basic operations on lists */
    459 
    460 bool
    461 isMember (const CanonicalForm& f, const CFList& F)
    462 {
    463   for (CFListIterator i= F; i.hasItem(); i++)
    464   {
    465     if (i.getItem().mapinto() == f.mapinto())
    466       return 1;
    467   }
    468   return 0;
    469 }
    470 
    471 /// are list A and B the same?
    472 bool
    473 isSame (const CFList& A, const CFList& B)
    474 {
    475   if (A.length() != B.length())
    476     return 0;
    477 
    478   CFListIterator i;
    479 
    480   for (i= A; i.hasItem(); i++)
    481   {
    482     if (!isMember (i.getItem(), B))
    483       return 0;
    484   }
    485   for (i= B; i.hasItem(); i++)
    486   {
    487     if (!isMember (i.getItem(), A))
    488       return 0;
    489   }
    490   return 1;
    491 }
    492 
    493 
    494 /// is List cs contained in List of lists pi?
    495 bool
    496 isMember (const CFList& cs, const ListCFList& pi)
    497 {
    498   if (pi.isEmpty())
    499     return 0;
    500 
    501   ListCFListIterator i;
    502 
    503   for (i= pi; i.hasItem(); i++)
    504   {
    505     if (i.getItem().length() != cs.length())
    506       continue;
    507     if (isSame (cs, i.getItem()))
    508       return 1;
    509   }
    510   return 0;
    511 }
    512 
    513459/// is PS a subset of Cset ?
    514460bool
     
    517463  for (CFListIterator i= PS; i.hasItem(); i++)
    518464  {
    519     if (!isMember (i.getItem(), Cset))
     465    if (!find (Cset, i.getItem()))
    520466      return 0;
    521467  }
    522468  return 1;
    523 }
    524 
    525 /// Union of two List of Lists
    526 ListCFList
    527 MyUnion (const ListCFList& a, const ListCFList& b)
    528 {
    529   if (a.isEmpty())
    530     return b;
    531   if (b.isEmpty())
    532     return a;
    533 
    534   ListCFList output;
    535   ListCFListIterator i;
    536   CFList elem;
    537 
    538   for (i= a; i.hasItem(); i++)
    539   {
    540     elem= i.getItem();
    541     if ((!elem.isEmpty()) && (!isMember (elem, output)))
    542       output.append(elem);
    543   }
    544 
    545   for (i= b; i.hasItem(); i++)
    546   {
    547     elem= i.getItem();
    548     if ((!elem.isEmpty()) && (!isMember (elem, output)))
    549       output.append(elem);
    550   }
    551   return output;
    552469}
    553470
     
    570487  {
    571488    elem= i.getItem();
    572     if ((!elem.isEmpty()) && (!isMember (elem, b)))
     489    if ((!elem.isEmpty()) && (!find (b, elem, operator==)))
    573490      b.insert(elem);
    574491  }
    575 }
    576 
    577 ///if list b is member of the list of lists a remove b and return the rest
    578 ListCFList
    579 minus (const ListCFList& a, const CFList& b)
    580 {
    581   ListCFList output;
    582   ListCFListIterator i;
    583   CFList elem;
    584 
    585   for (i= a; i.hasItem(); i++)
    586   {
    587     elem= i.getItem();
    588     if ((!elem.isEmpty()) && (!isSame (elem, b)))
    589       output.append (elem);
    590   }
    591   return output;
    592 }
    593 
    594 /// remove all elements of b from list of lists a and return the rest
    595 ListCFList
    596 minus (const ListCFList& a, const ListCFList& b)
    597 {
    598   ListCFList output= a;
    599 
    600   for (ListCFListIterator i= b; i.hasItem(); i++)
    601     output = minus (output, i.getItem());
    602 
    603   return output;
    604492}
    605493
     
    621509    return iss;
    622510
    623   qhi= minus (qh, qs);
     511  qhi= Difference (qh, qs, operator==);
    624512  length= qhi.length();
    625513
     
    659547  if (iscopy.isEmpty())
    660548    return iss;
    661   qhi= minus (qh, qs);
     549  qhi= Difference (qh, qs, operator==);
    662550  length= qhi.length();
    663551  for (i= iscopy; i.hasItem(); i++)
     
    1052940  {
    1053941    iitem= i.getItem();
    1054     if (!isMember (iitem, mem))
     942    if (!find (mem, iitem, operator==))
    1055943    {
    1056944      j= i;
     
    1059947      {
    1060948        jitem= j.getItem();
    1061         if (!isMember (jitem, mem))
     949        if (!find (mem, jitem, operator==))
    1062950        {
    1063951          if (contractsub (iitem, jitem))
     
    1075963    }
    1076964  }
    1077   return minus (cs,ts);
    1078 }
    1079 
     965  return Difference (cs,ts, operator==);
     966}
     967
  • factory/cfCharSetsUtil.h

    r8b7b108 rffb732  
    101101
    102102bool
    103 isMember (const CFList& cs, const ListCFList& pi);
    104 
    105 bool
    106103isSubset (const CFList &PS, const CFList& Cset);
    107 
    108 ListCFList
    109 minus (const ListCFList& a, const CFList& b);
    110104
    111105ListCFList
     
    115109adjoinb (const CFList & is, const CFList & qs, const ListCFList & qh,
    116110         const CFList & cs);
    117 
    118 ListCFList
    119 MyUnion (const ListCFList& a, const ListCFList& b);
    120111
    121112void
Note: See TracChangeset for help on using the changeset viewer.