24 ClassImp(TSeqCollection);
 
   30 Int_t TSeqCollection::IndexOf(
const TObject *obj)
 const 
   36    while ((ob = next())) {
 
   37       if (ob->IsEqual(obj)) 
return idx;
 
   47 Int_t TSeqCollection::GetLast()
 const 
   49    TObject *tmp = Last();
 
   50    return tmp ? IndexOf(tmp) : -1;
 
   56 Int_t TSeqCollection::ObjCompare(TObject *a, TObject *b)
 
   58    if (a == 0 && b == 0) 
return 0;
 
   60    if (b == 0) 
return -1;
 
   70 void TSeqCollection::QSort(TObject **a, Int_t first, Int_t last)
 
   72    R__LOCKGUARD2(gCollectionMutex);
 
   78    while (last - first > 1) {
 
   82          while (++i < last && ObjCompare(a[i], a[first]) < 0)
 
   84          while (--j > first && ObjCompare(a[j], a[first]) > 0)
 
  100       if (j - first < last - (j + 1)) {
 
  104          QSort(a, j + 1, last);
 
  118 void TSeqCollection::QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last)
 
  120    R__LOCKGUARD2(gCollectionMutex);
 
  122    static TObject *tmp1, **tmp2;
 
  126    static int depth = 0;
 
  127    if (depth == 0 && nBs > 0) tmp2 = 
new TObject*[nBs];
 
  130    while (last - first > 1) {
 
  134          while (++i < last && ObjCompare(a[i], a[first]) < 0) {}
 
  135          while (--j > first && ObjCompare(a[j], a[first]) > 0) {}
 
  138          tmp1 = a[i]; 
for(k=0;k<nBs;k++) tmp2[k] = b[k][i];
 
  139          a[i] = a[j]; 
for(k=0;k<nBs;k++) b[k][i] = b[k][j];
 
  140          a[j] = tmp1; 
for(k=0;k<nBs;k++) b[k][j] = tmp2[k];
 
  146       tmp1 = a[first]; 
for(k=0;k<nBs;k++) tmp2[k] = b[k][first];
 
  147       a[first] = a[j]; 
for(k=0;k<nBs;k++) b[k][first] = b[k][j];
 
  148       a[j] = tmp1; 
for(k=0;k<nBs;k++) b[k][j] = tmp2[k];
 
  149       if (j - first < last - (j + 1)) {
 
  150          QSort(a, nBs, b, first, j);
 
  153          QSort(a, nBs, b, j + 1, last);
 
  159    if (depth == 0 && nBs > 0) 
delete [] tmp2;
 
  185 Long64_t TSeqCollection::Merge(TCollection *list)
 
  187    Long64_t nmerged = 0;
 
  188    if (IsEmpty() || !list) {
 
  189       Warning(
"Merge", 
"list is empty - nothing to merge");
 
  192    if (list->IsEmpty()) {
 
  193       Warning(
"Merge", 
"input list is empty - nothing to merge with");
 
  196    TIter nextobject(
this);
 
  197    TIter nextlist(list);
 
  201    TSeqCollection *templist = 0;
 
  204    TSeqCollection *notmergeable = 0;
 
  205    Bool_t mergeable = kTRUE;
 
  206    while ((
object = nextobject())) {   
 
  209       if (!object->IsA()) {
 
  213          callEnv.InitWithPrototype(object->IsA(), 
"Merge", 
"TCollection*");
 
  214          if (!callEnv.IsValid()) mergeable = kFALSE;
 
  218          templist = (TSeqCollection*)IsA()->New();
 
  220          templist->SetOwner(kFALSE);
 
  226       while ((collcrt = nextlist())) {      
 
  227          if (!collcrt->InheritsFrom(TSeqCollection::Class())) {
 
  228             Error(
"Merge", 
"some objects in the input list are not collections - merging aborted");
 
  229             SafeDelete(templist);
 
  232          if (indobj > ((TSeqCollection*)collcrt)->LastIndex()) {
 
  238          objtomerge = ((TSeqCollection*)collcrt)->At(indobj);
 
  240             Warning(
"Merge", 
"object of type %s (position %d in list) not found in list %d. Continuing...",
 
  241                              object->ClassName(), indobj, indcoll);
 
  253          if (object->IsA() != objtomerge->IsA()) {
 
  254             Error(
"Merge", 
"object of type %s at index %d not matching object of type %s in input list",
 
  255                            object->ClassName(), indobj, objtomerge->ClassName());
 
  256             SafeDelete(templist);
 
  261             templist->Add(objtomerge);
 
  265             if (!notmergeable && IsA())
 
  266                notmergeable = (TSeqCollection*)IsA()->New();
 
  268                notmergeable->Add(objtomerge);
 
  270                Warning(
"Merge", 
"temp list for non mergeable objects not created!");
 
  275          callEnv.SetParam((Long_t) templist);
 
  276          callEnv.Execute(
object);
 
  277          SafeDelete(templist);
 
  283    if (notmergeable && notmergeable->GetSize() > 0) {
 
  284       TIter nxnm(notmergeable);
 
  286       while ((onm = nxnm())) { Add(onm->Clone()); }
 
  287       SafeDelete(notmergeable);