Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

BigListElement.C

Go to the documentation of this file.
00001 // BigListElement.C
00002 //
00003 // 2/11/98 WAH:  Broke away from Scheduler package; minor patching up.
00004 // 3/23/98 WAH:  Added RemovePredecessor and RemoveSuccessor methods.
00005 // 4/2/98 WAH:   Removed all sorts of destructor calls; fixed Ancestor-
00006 //               ClusterInfo and CopiedResultInfo inits in copy constructor
00007 //               and assignment (== instead of =); activated assignment
00008 //               operator - added copying of DagNode info, changed
00009 //               return value, reworked Predecessors/Successors copying,
00010 //               added test for self-assignment.
00011 
00012 #include <iostream.h>
00013 #include <fstream.h>
00014 #include "SmallListElement.H"
00015 #include "BigListElement.H"
00016 
00017 /* Debugging support, courtesy of Sumedh */
00018 // #define _BIGLISTELEMENT_DEBUG_
00019 #ifdef _BIGLISTELEMENT_DEBUG_
00020 #define derr(s)         cerr << s
00021 #else
00022 #define derr(s)
00023 #endif
00024 
00025 #define AddEntry(E,D,O,I,L,P);  { (E).SetDependencyType((D));   \
00026                                   (E).SetOp((O));               \
00027                                   (E).SetDagEntry((I));         \
00028                                   (L)->push_back((E));          \
00029                                   (P) = (L)->back(); }
00030 
00031 #define AddEntryBeginning(E,D,O,I,L,P); { (E).SetDependencyType((D));   \
00032                                   (E).SetOp((O));               \
00033                                   (E).SetDagEntry((I));         \
00034                                   (L)->insert((L)->begin(),(E));                \
00035                                   (P) = (L)->back(); }
00036 
00037 
00038 /* AddPredecessorBeginning: Add an Op as a data predecessor with an edge of type
00039    Dependency */
00040 int BigListElement::AddPredecessorBeginning( enum edgeTypes Dependency, legoOp *Op,
00041                                     BigListElement *Iter )
00042 {
00043    SmallListElement Element;
00044    SmallListElement Ptr;
00045 
00046    AddEntryBeginning( Element, Dependency, Op, Iter, Predecessors, Ptr );
00047 #if defined (_BIGLISTELEMENT_DEBUG_)
00048    derr ("** Cur Id " << GetOp()->GetOpId() << ", Predecessor "
00049         << Ptr.GetOp()->GetOpId() << "\n");
00050 #endif
00051    return Predecessors->size();
00052 }
00053 
00054 
00055 /* AddPredecessor: Add an Op as a data predecessor with an edge of type
00056    Dependency */
00057 int BigListElement::AddPredecessor( enum edgeTypes Dependency, legoOp *Op,
00058                                     BigListElement *Iter )
00059 {
00060    SmallListElement Element;
00061    SmallListElement Ptr;
00062 
00063    AddEntry( Element, Dependency, Op, Iter, Predecessors, Ptr );
00064 #if defined (_BIGLISTELEMENT_DEBUG_)
00065    derr ("** Cur Id " << GetOp()->GetOpId() << ", Predecessor "
00066         << Ptr.GetOp()->GetOpId() << "\n");
00067 #endif
00068    return Predecessors->size();
00069 }
00070 
00071 
00072 /* AddSuccessor: Add an Op as a data successor with an edge of type
00073    Dependency */
00074 int BigListElement::AddSuccessor( enum edgeTypes Dependency, legoOp *Op,
00075                                   BigListElement *Iter )
00076 {
00077    SmallListElement Element;
00078    SmallListElement Ptr;
00079 
00080    AddEntry( Element, Dependency, Op, Iter, Successors, Ptr );
00081 #if defined (_BIGLISTELEMENT_DEBUG_)
00082    derr ("** Cur Id " << GetOp()->GetOpId() << ", Successor "
00083         << Ptr.GetOp()->GetOpId() << "\n");
00084 #endif
00085    return Successors->size();
00086 }
00087 
00088 
00089 /* RemovePredecessor: Remove an Op as a data predecessor with an edge of type
00090    Dependency */
00091 /* DANGER!!! Predecessors and Successors are implemented as STL vectors.
00092    These two remove functions must use vector::erase, which MAY INVALIDATE
00093    ITERATORS INTO THE VECTORS! You'll have to handle that yourself, or
00094    reimplement using lists or some other STL class. */
00095 int BigListElement::RemovePredecessor( enum edgeTypes Dependency, legoOp *Op,
00096                                        BigListElement *Iter )
00097 {
00098    SmallListElement *Element;
00099    //   SmallListElement Ptr;
00100    int PredId = Op->GetOpId();
00101 
00102    //   AddEntry( Element, Dependency, Op, Iter, Predecessors, Ptr );
00103    vector < SmallListElement >::iterator Front, Back;
00104 
00105    for ( Front = Predecessors->begin(), Back = Predecessors->end();
00106          Front != Back; Front++ )
00107      {
00108        Element = &(*Front);
00109        if ( Element->GetOp() == Op &&
00110             Element->GetDagEntry() == Iter &&
00111             Element->GetDependencyType() == Dependency )
00112          {
00113            //      delete &(*Front);
00114            Predecessors->erase (Front);
00115 #if defined (_BIGLISTELEMENT_DEBUG_)
00116            derr ("** Cur Id " << GetOp()->GetOpId() << ", ~Predecessor "
00117                 << PredId << "\n");
00118 #endif
00119            break;
00120          } // end if
00121      } // end for
00122 
00123    return Predecessors->size();
00124 }
00125 
00126 
00127 /* RemoveSuccessor: Remove an Op as a data successor with an edge of type
00128    Dependency */
00129 int BigListElement::RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op,
00130                                        BigListElement *Iter )
00131 {
00132    SmallListElement *Element;
00133    //   SmallListElement Ptr;
00134    int SuccId = Op->GetOpId();
00135 
00136    //   AddEntry( Element, Dependency, Op, Iter, Successors, Ptr );
00137    vector < SmallListElement >::iterator Front, Back;
00138 
00139    for ( Front = Successors->begin(), Back = Successors->end();
00140          Front != Back; Front++ )
00141      {
00142        Element = &(*Front);
00143        if ( Element->GetOp() == Op &&
00144             Element->GetDagEntry() == Iter &&
00145             Element->GetDependencyType() == Dependency )
00146          {
00147            //      delete &(*Front);
00148            Successors->erase (Front);
00149 #if defined (_BIGLISTELEMENT_DEBUG_)
00150            derr ("** Cur Id " << GetOp()->GetOpId() << ", ~Successor "
00151                 << SuccId << "\n");
00152 #endif
00153            break;
00154          } // end if
00155      } // end for
00156         
00157    return Successors->size();
00158 }
00159 
00160 
00161 /* RemovePredecessor: Remove an Op as a data predecessor with an edge of type
00162    Dependency */
00163 /* DANGER!!! Predecessors and Successors are implemented as STL vectors.
00164    These two remove functions must use vector::erase, which MAY INVALIDATE
00165    ITERATORS INTO THE VECTORS! You'll have to handle that yourself, or
00166    reimplement using lists or some other STL class. */
00167 vector < SmallListElement >::iterator 
00168 BigListElement::RemovePredecessor( enum edgeTypes Dependency, legoOp *Op )
00169 {
00170    SmallListElement *Element;
00171    //   SmallListElement Ptr;
00172    int PredId = Op->GetOpId();
00173 
00174    vector < SmallListElement >::iterator Front, Back, returniter;
00175 
00176    for ( Front = Predecessors->begin(), Back = Predecessors->end();
00177          Front != Back; Front++ )
00178      {
00179        Element = &(*Front);
00180        if ( Element->GetOp() == Op &&
00181             Element->GetDependencyType() == Dependency )
00182          {
00183            //      delete &(*Front);
00184            returniter = Predecessors->erase (Front);
00185            derr ("\nRemoved !!!   Size now = " << Predecessors->size());
00186 #if defined (_BIGLISTELEMENT_DEBUG_)
00187            derr ("** Cur Id " << GetOp()->GetOpId() << ", ~Predecessor "
00188                 << PredId << "\n");
00189 #endif
00190            return returniter;
00191          } // end if
00192        else {
00193          returniter = Predecessors->end(); 
00194        }
00195      } // end for
00196 
00197    derr ("\nNot Removed ???   Size now = " << Predecessors->size());
00198    return returniter;
00199 }
00200 
00201 
00202 /* RemoveSuccessor: Remove an Op as a data successor with an edge of type
00203    Dependency */
00204 vector < SmallListElement >::iterator 
00205 BigListElement::RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op )
00206 {
00207    SmallListElement *Element;
00208    //   SmallListElement Ptr;
00209    int SuccId = Op->GetOpId();
00210 
00211    vector < SmallListElement >::iterator Front, Back, returniter;
00212 
00213    for ( Front = Successors->begin(), Back = Successors->end();
00214          Front != Back; Front++ )
00215      {
00216        Element = &(*Front);
00217        if ( Element->GetOp() == Op &&
00218             Element->GetDependencyType() == Dependency )
00219          {
00220            //      delete &(*Front);
00221            returniter = Successors->erase (Front);
00222            derr ("\nRemoved !!!   Size now = " << Successors->size());
00223 #if defined (_BIGLISTELEMENT_DEBUG_)
00224            derr ("** Cur Id " << GetOp()->GetOpId() << ", ~Successor "
00225                 << SuccId << "\n");
00226 #endif
00227            return returniter;
00228          } // end if
00229        else {
00230          returniter = Successors->end(); 
00231        }
00232      } // end for
00233         
00234    derr ("\nNot Removed ???   Size now = " << Successors->size());
00235    return returniter;
00236 }
00237 
00238 
00239 /* CompareIds: returns 1 NodeOne has a smaller OpId, 0 otherwise */
00240 static int CompareIds( SmallListElement NodeOne, SmallListElement NodeTwo )
00241 {
00242    int Opid1, Opid2, rc;
00243 
00244 #if 0
00245    Opid1 = NodeOne.GetOp()->GetOpId();
00246    Opid2 = NodeTwo.GetOp()->GetOpId();
00247 #if 0
00248    cerr << ">> CompareOpIds(1): Op 1-"
00249         << NodeOne.GetDagEntry()->GetOp()->GetOpId() << ", Op 2-"
00250         << NodeTwo.GetDagEntry()->GetOp()->GetOpId() << "\n";
00251    cerr << ">> CompareOpIds(2): Op 1-"
00252         << NodeOne.GetOp()->GetOpId() << ", Op 2-"
00253         << NodeTwo.GetOp()->GetOpId() << "\n";
00254 #endif
00255 #else
00256    Opid1 = NodeOne.GetDagEntry()->GetOp()->GetOpId();
00257    Opid2 = NodeTwo.GetDagEntry()->GetOp()->GetOpId();
00258 #endif
00259    derr( ">> CompareOpIds: Op 1-" << Opid1 << ", Op 2-" << Opid2 << "\n" );
00260    rc = Opid1 > Opid2;
00261 
00262    return rc;
00263 }
00264 
00265 /* CompareWeights: returns 1 NodeOne has a smaller profile weight,
00266    0 otherwise */
00267 static int CompareWeights( SmallListElement NodeOne, SmallListElement NodeTwo )
00268 {
00269    return NodeOne.GetDagEntry()->GetWeight() >
00270           NodeTwo.GetDagEntry()->GetWeight();
00271 }
00272 
00273 
00274 /* CompareHeights: returns 1 NodeOne has a lesser height, 0 otherwise */
00275 static int CompareHeights( SmallListElement NodeOne, SmallListElement NodeTwo )
00276 {
00277    return NodeOne.GetDagEntry()->GetHeight() >
00278           NodeTwo.GetDagEntry()->GetHeight();
00279 }
00280 
00281 
00282 /* CompareDepths: returns 1 NodeOne has a lesser depth, 0 otherwise */
00283 static int CompareDepths( SmallListElement NodeOne, SmallListElement NodeTwo )
00284 {
00285    return NodeOne.GetDagEntry()->GetDepth() >
00286           NodeTwo.GetDagEntry()->GetDepth();
00287 }
00288 
00289 
00290 /* CompareValues: returns 1 NodeOne has a lesser Value field, 0 otherwise */
00291 static int CompareValues( SmallListElement NodeOne, SmallListElement NodeTwo )
00292 {
00293    return NodeOne.GetDagEntry()->Value > NodeTwo.GetDagEntry()->Value;
00294 }
00295 
00296 
00297 // BubbleSort:
00298 void BigListElement::BubbleSort( vector < SmallListElement > *Vector,
00299                                  int (*Compare)( SmallListElement,
00300                                                  SmallListElement ) )
00301 {
00302    int i, size;
00303    SmallListElement *Element, Element1;
00304    vector < SmallListElement >::iterator Front, Back, SubFront, SubBack, Max;
00305 
00306 
00307    derr( ">> BigListElement::BubbleSort\n" );
00308 
00309    // Until all nodes are examined, continue
00310    for ( size = Vector->size(), i = 0, Front = Vector->begin(),
00311          Back = Vector->end(); Front != Back; Front++, i++ ) {
00312 
00313       // Set the current list element as the maximum element
00314       Max = Front;
00315 
00316       // Compare all elements from this one down to the end
00317       // Keep an iterator to the largest one found
00318       for ( SubFront = Front; SubFront != Back; SubFront++ ) {
00319          if ( Compare( (*SubFront), (*Max) ) == 1 )
00320             Max = SubFront;
00321       }
00322       derr( "   ** New Max: Op " << (*Max).GetOp()->GetOpId() << "\n" );
00323 
00324       // Place the new max element into the n-th place in the list. If
00325       // the max element is the same as before the list was examined,
00326       // there is no need for the copy.
00327       if ( Max != Front ) {
00328          derr( "   Swapping Ops " << (*Max).GetDagEntry()->GetOp()->GetOpId()
00329                << " and " << (*Front).GetDagEntry()->GetOp()->GetOpId()
00330                << "\n" );
00331          // Element = new SmallListElement( *Max );
00332          //         Element1.SmallListElement( *Max );
00333          Element1 = *Max;  // wah 3/24/98
00334 #if 0
00335          // (*Max).~SmallListElement();
00336          (*Max).SmallListElement( (*Vector)[ i ] );
00337          // (*Vector)[ i ].~SmallListElement();
00338          // (*Vector)[ i ].SmallListElement( *Element );
00339          (*Vector)[ i ].SmallListElement( Element1 );
00340 #else
00341          *Max = (*Vector)[ i ];
00342          (*Vector)[ i ] = Element1;
00343 #endif
00344       }
00345    }
00346    derr( "<< BigListElement::BubbleSort\n" );
00347 }
00348 
00349 
00350 /* SortList */
00351 void BigListElement::SortList( vector <SmallListElement> *List,
00352                       int (*Compare)( SmallListElement, SmallListElement ) )
00353 {
00354    sort( (*List).begin(), (*List).end(), Compare );
00355    // BubbleSort( List, Compare );
00356 }
00357 
00358 
00359 /* SortSuccessorsByOpId */
00360 void BigListElement::SortSuccessorsByOpId()
00361 {
00362    SortList( Successors, CompareIds );
00363 }
00364 
00365 
00366 /* SortSuccessorsByHeight */
00367 void BigListElement::SortSuccessorsByHeight()
00368 {
00369    SortList( Successors, CompareHeights );
00370 }
00371 
00372 
00373 /* SortSuccessorsByWeight */
00374 void BigListElement::SortSuccessorsByWeight()
00375 {
00376    SortList( Successors, CompareWeights );
00377 }
00378 
00379 
00380 /* SortSuccessorsByDepth */
00381 void BigListElement::SortSuccessorsByDepth()
00382 {
00383    SortList( Successors, CompareDepths );
00384 }
00385 
00386 
00387 /* SortSuccessorsByValue */
00388 void BigListElement::SortSuccessorsByValue()
00389 {
00390    SortList( Successors, CompareValues );
00391 }
00392 
00393 
00394 /* SortPredecessorsByOpId */
00395 void BigListElement::SortPredecessorsByOpId()
00396 {
00397    SortList( Predecessors, CompareIds );
00398 }
00399 
00400 
00401 /* SortPredecessorsByHeight */
00402 void BigListElement::SortPredecessorsByHeight()
00403 {
00404    SortList( Predecessors, CompareHeights );
00405 }
00406 
00407 
00408 /* SortPredecessorsByWeight */
00409 void BigListElement::SortPredecessorsByWeight()
00410 {
00411    SortList( Predecessors, CompareWeights );
00412 }
00413 
00414 
00415 /* SortPredecessorsByDepth */
00416 void BigListElement::SortPredecessorsByDepth()
00417 {
00418    SortList( Predecessors, CompareDepths );
00419 }
00420 
00421 
00422 /* SortPredecessorsByValue */
00423 void BigListElement::SortPredecessorsByValue()
00424 {
00425    SortList( Predecessors, CompareValues );
00426 }
00427 
00428 
00429 // FreeSmallVector: deallocate all memory stored with elements in a vector
00430 //    of SmallListElements
00431 void FreeSmallVector( vector < SmallListElement >::iterator Front,
00432                       vector < SmallListElement >::iterator Back )
00433 {
00434    return;
00435 }
00436 
00437 
00438 // Allocate_AncestorClusterInfo - allocate an array of size n (> 0)
00439 void BigListElement::Allocate_AncestorClusterInfo( int n )
00440 {     
00441    if ( n > 0 && a_array_size == 0 ) {  // allocate 'positive' space
00442                                         // and don't allow reallocations
00443       AncestorClusterInfo = new int [ n ];
00444       a_array_size = n;
00445    }
00446 }
00447 
00448 
00449 // InitAncestorClusterInfo - sets all entries to -1
00450 void BigListElement::InitAncestorClusterInfo()
00451 {
00452    int i;
00453 
00454    if ( a_array_size > 0 )
00455       for ( i = 0; i < a_array_size; i++ ) AncestorClusterInfo[ i ] = -1;
00456 }
00457 
00458 
00459 // Allocate_CopiedResultInfo
00460 void BigListElement::Allocate_CopiedResultInfo( int n )
00461 {
00462    if ( n > 0 && c_array_size ==  0 ) { // allocate 'positive' space
00463                                         // and don't allow reallocations
00464       int i;
00465 
00466       CopiedResultInfo = new int [ n ];
00467       c_array_size = n;
00468       for ( i = 0; i < c_array_size; i++ ) CopiedResultInfo[ i ] = 0;
00469    }
00470 }
00471 
00472 
00473 // PrintElement: as it says
00474 void BigListElement::PrintElement()
00475 {
00476    cerr.width(4);
00477    cerr << "Opid " << GetOp()->GetOpId() << "\tHeight: " << GetHeight()
00478         << "\tDepth: " << GetDepth() << "\n\tWeight: "
00479         << GetWeight() << "\tValue: " << Value << "\tClusterid: " << ClusterId
00480         << "\n";
00481    cerr << "\tPOINTS TO: ";
00482    if ( NumSuccessors() == 0 ) cerr << "*** Exit Node ***\n";
00483    else {
00484       cerr << "(" << NumSuccessors() << ")";
00485       PrintList( Successors );
00486    }
00487    cerr << "\tDEPENDS ON: ";
00488    if ( NumPredecessors() == 0 ) cerr << "*** Entry Node ***\n";
00489    else {
00490       cerr << "(" << NumPredecessors() << ")";
00491       PrintList( Predecessors );
00492    }
00493 }
00494 
00495 //HZ: 8/24/00
00496 // PrintElement: as it say (to a stream)
00497 void BigListElement::PrintElement(ofstream & os1)
00498 {
00499    os1.width(4);
00500    os1 << "Opid " << GetOp()->GetOpId() << "\tHeight: " << GetHeight()
00501         << "\tDepth: " << GetDepth() << "\n\tWeight: "
00502         << GetWeight() << "\tValue: " << Value << "\tClusterid: " << ClusterId
00503         << "\n";
00504    os1 << "\tPOINTS TO: ";
00505    if ( NumSuccessors() == 0 ) os1 << "*** Exit Node ***\n";
00506    else {
00507       os1 << "(" << NumSuccessors() << ")";
00508       PrintList( Successors, os1 );
00509    }
00510    os1 << "\tDEPENDS ON: ";
00511    if ( NumPredecessors() == 0 ) os1 << "*** Entry Node ***\n";
00512    else {
00513       os1 << "(" << NumPredecessors() << ")";
00514       PrintList( Predecessors, os1 );
00515    }
00516 }
00517 
00518 /* Constructor */
00519 BigListElement::BigListElement()
00520 {
00521    ClusterId = -1;
00522    Value = 0;
00523    a_array_size = 0;
00524    c_array_size = 0;
00525    Predecessors = new vector < SmallListElement >;
00526    Successors = new vector < SmallListElement >;
00527 }
00528 
00529 
00530 /* Destructor */
00531 BigListElement::~BigListElement()
00532 {
00533    int size, i;
00534 
00535    DestructSmallVector( Predecessors );
00536    delete Predecessors;
00537    DestructSmallVector( Successors );
00538    delete Successors;
00539    if ( a_array_size > 0 ) delete[] AncestorClusterInfo;
00540    if ( c_array_size > 0 ) delete[] CopiedResultInfo;
00541 }
00542 
00543 
00544 /* Copy constructor */
00545 BigListElement::BigListElement( const BigListElement &src ) :
00546    DagNode( (DagNode) src )
00547 {
00548    vector < SmallListElement >::iterator Front, Back;
00549    vector < SmallListElement > *Vptr;
00550    SmallListElement *ElementPtr, Tmp;
00551    int size, i;
00552 
00553 
00554    derr( ">> BigListElement::copy constructor\n" );
00555 
00556    ClusterId = src.ClusterId;
00557    Value = src.Value;
00558    a_array_size = src.a_array_size;
00559    c_array_size = src.c_array_size;
00560 
00561    // Copy the current AncestorClusterInfo array
00562    if ( src.a_array_size > 0 ) {
00563       AncestorClusterInfo = new int [ a_array_size ];
00564       for ( i = 0; i < a_array_size; i++ )
00565          AncestorClusterInfo[ i ] = src.AncestorClusterInfo[ i ];
00566    }
00567    else AncestorClusterInfo = NULL;
00568 
00569    // Copy the current CopiedResultInfo array
00570    if ( src.c_array_size > 0 ) {
00571       CopiedResultInfo = new int [ c_array_size ];
00572       for ( i = 0; i < c_array_size; i++ )
00573          CopiedResultInfo[ i ] = src.CopiedResultInfo[ i ];
00574    }
00575    else CopiedResultInfo = NULL;
00576 
00577    // wah 3/24/98 Reworked Predecessors/Successors construction
00578    // Should the current Predecessors be destroyed? Or do we assume that
00579    // it doesn't exist?
00580    // DestructSmallVector( Predecessors );
00581    //   Predecessors = new vector < SmallListElement >;
00582    Vptr = src.Predecessors;
00583    Front = Vptr->begin();
00584    Back = Vptr->end();
00585 
00586    derr( "   Original predecessors\n" );
00587    // PrintList( Vptr );
00588    // Use the copy constructors of the STL data structures
00589    derr( "   Copying predecessors..." );
00590    //   Predecessors->vector( Front, Back );
00591    Predecessors = new vector < SmallListElement > ( Front, Back );
00592    derr( "Copied predecessors\n" );
00593    // PrintList( Predecessors );
00594 
00595    // Should the current Successors be destroyed? Or do we assume that
00596    // it doesn't exist?
00597    // DestructSmallVector( Successors );
00598    //   Successors = new vector < SmallListElement >;
00599    Vptr = src.Successors;
00600    Front = Vptr->begin();
00601    Back = Vptr->end();
00602 
00603    derr( "   Original successors\n" );
00604    // PrintList( Vptr );
00605    // Use the copy constructors of the STL data structures
00606    derr( "   Copying successors..." );
00607    //   Successors->vector( Front, Back );
00608    Successors = new vector < SmallListElement > ( Front, Back );
00609    derr( "Copied successors\n" );
00610    derr( "<< BigListElement::copy constructor\n" );
00611 }
00612 
00613 #if 1
00614 /* = operator */
00615 BigListElement & BigListElement::operator=(const BigListElement &src )
00616 {
00617    vector < SmallListElement >::iterator Front, Back;
00618    vector < SmallListElement > *Vptr;
00619    SmallListElement *ElementPtr, Tmp;
00620    int size, i;
00621 
00622 
00623    if (&src == this) return *this;
00624    derr( ">> BigListElement: = operator\n" );
00625 
00626    // Copy DagNode members!
00627    height = src.height;
00628    depth = src.depth;
00629    cycle = src.cycle;
00630    ProfileWeight = src.ProfileWeight;
00631    Op = src.Op;
00632 
00633    ClusterId = src.ClusterId;
00634    Value = src.Value;
00635    a_array_size = src.a_array_size;
00636    c_array_size = src.c_array_size;
00637 
00638    // Copy the current AncestorClusterInfo array
00639    if ( src.a_array_size > 0 ) {
00640       AncestorClusterInfo = new int [ a_array_size ];
00641       for ( i = 0; i < a_array_size; i++ )
00642          AncestorClusterInfo[ i ] = src.AncestorClusterInfo[ i ];
00643    }
00644    else AncestorClusterInfo = NULL;
00645 
00646    // Copy the current CopiedResultInfo array
00647    if ( src.c_array_size > 0 ) {
00648       CopiedResultInfo = new int [ c_array_size ];
00649       for ( i = 0; i < c_array_size; i++ )
00650          CopiedResultInfo[ i ] = src.CopiedResultInfo[ i ];
00651    }
00652    else CopiedResultInfo = NULL;
00653 
00654    DestructSmallVector( Predecessors );
00655    delete Predecessors;
00656    Vptr = src.Predecessors;
00657    Front = Vptr->begin();
00658    Back = Vptr->end();
00659    // Use the copy constructors of the STL data structures
00660    //   derr( "   Copying predecessors..." );
00661    Predecessors = new vector < SmallListElement > ( Front, Back );
00662 
00663    //   derr( "   Original predecessors\n" );
00664    // PrintList( Vptr );
00665    //   derr( "Copied predecessors\n" );
00666    // PrintList( Predecessors );
00667 
00668    DestructSmallVector( Successors );
00669    delete Successors;
00670    Vptr = src.Successors;
00671    Front = Vptr->begin();
00672    Back = Vptr->end();
00673    // Use the copy constructors of the STL data structures
00674    //   derr( "   Copying successors..." );
00675    Successors = new vector < SmallListElement > ( Front, Back );
00676 
00677    //   derr( "   Original successors\n" );
00678    // PrintList( Vptr );
00679    //   derr( "Copied successors\n" );
00680    // PrintList( Successors );
00681 
00682    derr( "<< BigListElement: = operator\n" );
00683    return *this;
00684 }
00685 #endif
00686 
00687 
00688 /***************************** Utility functions *********************/
00689 
00690 /******************* BEGIN ****************/
00691 
00692 // DestructBigVector:  destructs a vector of of BigListElements
00693 void DestructBigVector( vector < BigListElement > *Vector )
00694 {
00695    (*Vector).erase( (*Vector).begin(), (*Vector).end() );
00696 
00697    return;
00698 }
00699 
00700 
00701 // DestructBigList:  destructs a list of of BigListElements
00702 void DestructBigList( list < BigListElement > *List )
00703 {
00704    (*List).erase( (*List).begin(), (*List).end() );
00705 
00706    return;
00707 }
00708 
00709 
00710 // CopyBigVector: copy elements from Src to Target
00711 int CopyBigVector( vector < BigListElement > *Src,
00712                    vector < BigListElement > *Target )
00713 {
00714    vector < BigListElement >::iterator Front, Back;
00715    BigListElement *Element;
00716 
00717    (*Target).reserve( (*Src).size() );
00718    for ( Front = (*Src).begin(), Back = (*Src).end(); Front != Back; Front++ ) {
00719       Element = new BigListElement( *Front );
00720       (*Target).push_back( *Element );
00721    }
00722    return( (*Target).size() );
00723 }
00724 
00725 
00726 //FindOpInBigList
00727 int FindOpInList( vector < BigListElement > *V, int OpId )
00728 {
00729    int i, size; 
00730    BigListElement Element;
00731 
00732 
00733    if ( (size=(*V).size()) == 0 ) return -1;
00734    for ( i = 0; i < size; i++ )
00735       if ( (*V)[ i ].GetOp()->GetOpId() == OpId )
00736          return i;
00737 
00738    return -1;
00739 }
00740 
00741 
00742 // FindNode: find Op w/'OpId' in the vector V.
00743 vector < BigListElement >::iterator FindNode( int OpId,
00744                                               vector < BigListElement > *V )
00745 {
00746    vector < BigListElement >::iterator Front, Back;
00747 
00748 
00749    for ( Front = V->begin(), Back = V->end(); Front != Back; Front++ )
00750       if ( (*Front).GetOp()->GetOpId() == OpId ) return Front;
00751 
00752    return V->end();
00753 }
00754 
00755 /******************** END *****************/

Generated on Mon Jul 21 20:24:01 2003 for TINKER LEGO DOC by doxygen 1.3.2