src/HSLib/GenOp.cc
// Input		Op   : General operator (this).
// 			limit: Representation limit number 
// Output		none : Insures number of Op reps
//			       does not exceed limit
// Note                      : This very simple function is quite
//                             critical. It keeps the number of
//                             operator representations from
//			       becoming infinitely large!
Input          Op   : General operator (this).
limit: Representation limit number
Output         none : Insures number of Op reps
does not exceed limit
Note                      : This very simple function is quite
critical. It keeps the number of
operator representations from
becoming infinitely large!
Input Op : General operator ( this ) . limit : Representation limit number Output none : Insures number of Op reps does not exceed limit Note : This very simple function is quite critical . It keeps the number of operator representations from becoming infinitely large!
void gen_op::SetLimits(int limit) const
  {
  LimCheck(limit);				
  if(!WBR) return; 				
  if(int(size()) <= limit) return;		
# ifdef OpDebug
  std::cout << "\n\tLimiting No. Of ";
  if(OpName.length()) std::cout << OpName << " ";
  std::cout << "Operator Representations";
  std::cout << "\n\tCurrent Representations: " 
            << size();
  std::cout << ", Maximum Allowed: " << limit; 
# endif
  gen_op* OpTmp = const_cast<gen_op*>(this);	
  genoprep* REP = NULL;				
  genoprep* LP  = NULL;				
  int PtyMin;					
  std::vector<genoprep>::iterator item;		
  std::vector<genoprep>::iterator lpi;
  while(int(size()) > limit)			
    {						
    REP  = (*OpTmp).Obegin();			
    item = (*OpTmp).begin();			
    if(REP==WBR) { REP++; item++; } 		
    PtyMin = REP->RepPty;			
    LP = REP; 					
    lpi = item;
    while(item != (*OpTmp).end())		
      {						
      if(REP->RepPty<PtyMin && REP!=WBR)	
        { 					
        PtyMin = REP->RepPty;			
        LP = REP;				
        lpi = item;				
        }
      REP++;					
      item++;
      }
    (*OpTmp).erase(lpi);			
    }						
  }
void gen_op :: SetLimits ( int limit ) const { LimCheck ( limit ) ; if ( ! WBR ) return ; if ( int ( size ( ) ) <= limit ) return ; # ifdef OpDebug std :: cout << " \n \t " ; if ( OpName . length ( ) ) std :: cout << OpName << " " ; std :: cout << " " ; std :: cout << " \n \t " << size ( ) ; std :: cout << " " << limit ; # endif gen_op * OpTmp = const_cast < gen_op * > ( this ) ; genoprep * REP = NULL ; genoprep * LP = NULL ; int PtyMin ; std :: vector < genoprep > :: iterator item ; std :: vector < genoprep > :: iterator lpi ; while ( int ( size ( ) ) > limit ) { REP = ( * OpTmp ) . Obegin ( ) ; item = ( * OpTmp ) . begin ( ) ; if ( REP == WBR ) { REP ++ ; item ++ ; } PtyMin = REP -> RepPty ; LP = REP ; lpi = item ; while ( item != ( * OpTmp ) . end ( ) ) { if ( REP -> RepPty < PtyMin && REP != WBR ) { PtyMin = REP -> RepPty ; LP = REP ; lpi = item ; } REP ++ ; item ++ ; } ( * OpTmp ) . erase ( lpi ) ; } }
Input          Op   : General operator (this).
Input Op : General operator ( this ) .
// Insure value reasonable // Don't do anything if NULL Op // Do nothing limit not exceeded // Cast away const (mutable!) // Pointer to OpRep // Another pointer to OpRep // For OpRep priority checking // Iterator into list // Since # OpReps>limit we have // to delete some of them. //   Get at 1st OpRep (genoprep*)  //   Same but vector iterator //   Must insure that NOT WBR //   Set initial priority value //   Set intiial OpRep pointer  //   Loop rest of OpRep list //   & find low priority OpRep //     Reset low priority rep //     if necessary //	 Lowest Oprep priority //	 Lowest priority OpRep //       Pointer to low one //   Go to next OpRep in list // Delete lowest priority OpRep // See if we must delete another // sosi - the use of erase has now been found to change //        the OpRep pointers. Does this mess up because of it?  Might //        have to do some bookkeeping explicitly for this to work then....