14 Int_t ProcFileElements::ProcFileElement::Compare(
const TObject *o)
const
22 const ProcFileElements::ProcFileElement *e =
23 dynamic_cast<const ProcFileElements::ProcFileElement *
>(o);
26 if (fFirst == e->fFirst) {
29 }
else if (fFirst < e->fFirst) {
39 Int_t ProcFileElements::ProcFileElement::Overlapping(ProcFileElement *e)
49 if (fFirst == 0 && fLast == -1) {
54 if (fFirst < e->fFirst) {
56 if (fLast < e->fFirst - 1) {
61 if (fLast == e->fFirst - 1) {
73 }
else if (fFirst == e->fFirst) {
75 if (fFirst == fLast || e->fFirst == e->fLast)
return 0;
80 if (e->fLast < fFirst - 1) {
85 if (e->fLast == fFirst - 1) {
100 Warning(
"Overlapping",
"should never be here!");
105 Int_t ProcFileElements::ProcFileElement::MergeElement(ProcFileElement *e)
111 if (Overlapping(e) < 0)
return -1;
114 if (e->fFirst < fFirst) fFirst = e->fFirst;
117 if (fLast == -1 || e->fLast == -1) {
120 if (fLast < e->fLast) fLast = e->fLast;
127 void ProcFileElements::ProcFileElement::Print(Option_t *)
const
131 Printf(
"\tfirst: %lld\t last: %lld", fFirst, fLast);
135 Int_t ProcFileElements::Add(Long64_t fst, Long64_t lst)
141 if (!fElements) fElements =
new TSortedList;
143 Error(
"Add",
"could not create internal list!");
148 ProcFileElements::ProcFileElement *ne =
149 new ProcFileElements::ProcFileElement(fst, lst);
152 TIter nxe(fElements);
153 ProcFileElements::ProcFileElement *e = 0;
154 while ((e = (ProcFileElements::ProcFileElement *)nxe())) {
155 if (e->MergeElement(ne) == 0)
break;
161 fElements->Remove(e);
174 ProcFileElements::ProcFileElement *ep = 0, *en = 0;
175 TObjLink *olp = fElements->FirstLink(), *oln = 0;
176 while (olp && (ep = (ProcFileElements::ProcFileElement *) olp->GetObject())) {
179 if ((en = (ProcFileElements::ProcFileElement *) oln->GetObject())) {
180 if (ep->MergeElement(en) == 0) {
181 fElements->Remove(en);
191 if ((e = (ProcFileElements::ProcFileElement *) fElements->First())) fFirst = e->fFirst;
192 if ((e = (ProcFileElements::ProcFileElement *) fElements->Last())) fLast = e->fLast;
199 void ProcFileElements::Print(Option_t *)
const
203 Printf(
"--- ProcFileElements ----------------------------------------");
204 Printf(
" File: %s", fName.Data());
205 Printf(
" # proc elements: %d", fElements ? fElements->GetSize() : 0);
206 TIter nxe(fElements);
207 ProcFileElements::ProcFileElement *e = 0;
208 while ((e = (ProcFileElements::ProcFileElement *)nxe())) { e->Print(); }
209 Printf(
" Raw overall range: [%lld, %lld]", fFirst, fLast);
210 Printf(
"-------------------------------------------------------------");
214 Int_t ProcFileElements::Merge(TCollection *li)
221 if (li->GetSize() <= 0)
return 0;
225 ProcFileElements *pfe = 0;
226 while ((pfe = (ProcFileElements *) nxo())) {
227 if (strcmp(GetName(), pfe->GetName()))
228 Warning(
"Merge",
"merging objects of different name! ('%s' != '%s')",
229 GetName(), pfe->GetName());
230 TIter nxe(pfe->GetListOfElements());
231 ProcFileElements::ProcFileElement *e = 0;
232 while ((e = (ProcFileElements::ProcFileElement *)nxe())) {
233 Int_t rc = Add(e->fFirst, e->fLast);