X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUON2DMapIteratorByI.cxx;h=2f1e0937b6489159fdcae4c7a7f82386c6d049a9;hb=6a341fb568684b64e50b8802eec91667d5c64e75;hp=b4084075a0e37b668c82fa77c4517c92a9b9c664;hpb=7332f2137636d05e01a719ff4e7b21a214894a29;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUON2DMapIteratorByI.cxx b/MUON/AliMUON2DMapIteratorByI.cxx index b4084075a0e..2f1e0937b64 100644 --- a/MUON/AliMUON2DMapIteratorByI.cxx +++ b/MUON/AliMUON2DMapIteratorByI.cxx @@ -28,77 +28,35 @@ //----------------------------------------------------------------------------- #include "AliMUON2DMapIteratorByI.h" - +#include "AliMpExMapIterator.h" #include "AliMpExMap.h" +#include "AliLog.h" /// \cond CLASSIMP ClassImp(AliMUON2DMapIteratorByI) /// \endcond //_____________________________________________________________________________ -AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMpExMap& theMap, - Int_t firstI, - Int_t lastI) +AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMpExMap& theMap, Int_t firstI, Int_t lastI) : TIterator(), fkMap(&theMap), +fIter1(theMap.CreateIterator()), fIter2(0x0), -fCurrentI(-1), -fCurrentJ(-1), fFirstI(firstI), -fLastI(lastI) +fLastI(lastI), +fCurrentI(-1) { /// default ctor Reset(); } //_____________________________________________________________________________ -AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMUON2DMapIteratorByI& rhs) -:TIterator(rhs), -fkMap(rhs.fkMap), -fIter2(0x0), -fCurrentI(rhs.fCurrentI), -fCurrentJ(rhs.fCurrentJ), -fFirstI(rhs.fFirstI), -fLastI(rhs.fLastI) -{ - /// copy ctor - if ( rhs.fIter2 ) fIter2 = new TExMapIter(*(rhs.fIter2)); -} - -//_____________________________________________________________________________ -AliMUON2DMapIteratorByI& -AliMUON2DMapIteratorByI::operator=(const AliMUON2DMapIteratorByI& rhs) -{ - /// assignment operator - if ( this != &rhs ) - { - fkMap = rhs.fkMap; - fIter2 = 0x0; - if ( rhs.fIter2 ) fIter2 = new TExMapIter(*(rhs.fIter2)); - fCurrentI = rhs.fCurrentI; - fCurrentJ = rhs.fCurrentJ; - fFirstI = rhs.fFirstI; - fLastI = rhs.fLastI; - } - return *this; -} - -//_____________________________________________________________________________ -TIterator& -AliMUON2DMapIteratorByI::operator=(const TIterator& rhs) +AliMUON2DMapIteratorByI& +AliMUON2DMapIteratorByI::operator=(const TIterator& /*rhs*/) { - /// overriden assigment operator (imposed by Root's declaration of TIterator ?) - if ( this != &rhs && rhs.IsA() == AliMUON2DMapIteratorByI::Class() ) - { - const AliMUON2DMapIteratorByI& rhs1 = static_cast(rhs); - fkMap = rhs1.fkMap; - fIter2 = 0x0; - if ( rhs1.fIter2 ) fIter2 = new TExMapIter(*(rhs1.fIter2)); - fCurrentI = rhs1.fCurrentI; - fCurrentJ = rhs1.fCurrentJ; - fFirstI = rhs1.fFirstI; - fLastI = rhs1.fLastI; - } + // overriden operator= (imposed by Root's definition of TIterator::operator= ?) + + AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor return *this; } @@ -106,6 +64,7 @@ AliMUON2DMapIteratorByI::operator=(const TIterator& rhs) AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI() { /// dtor + delete fIter1; delete fIter2; } @@ -113,49 +72,41 @@ AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI() const TCollection* AliMUON2DMapIteratorByI::GetCollection() const { - /// Not implemented + /// Return 0 as we're not really dealing with a Root TCollection... return 0x0; } //_____________________________________________________________________________ -TObject* -AliMUON2DMapIteratorByI::GetValue(TExMapIter& iter, Int_t& theKey) const +AliMpExMapIterator* +AliMUON2DMapIteratorByI::NextIterator() { - /// return the value corresponding to theKey in iterator iter - theKey = -1; - Long_t key, value; - Bool_t ok = iter.Next(key,value); - if (!ok) return 0x0; - theKey = (Int_t)(key & 0xFFFF); - return reinterpret_cast(value); + /// Get next map (from fIter1) and create an iterator to it + + AliMpExMap* m = static_cast(fIter1->Next(fCurrentI)); + + if (!m) return 0x0; + + if ( fCurrentI < fFirstI || fCurrentI > fLastI ) return NextIterator(); // try again + + return m->CreateIterator(); } //_____________________________________________________________________________ TObject* AliMUON2DMapIteratorByI::Next() { - /// logic : - /// get TObject* from fIter2 - /// if null, increment fIter2 by getting next map from fMap - + /// return next object + if (!fIter2) return 0x0; - TObject* o = GetValue(*fIter2,fCurrentJ); + TObject* o = fIter2->Next(); + if (!o) { - // fIter2 exhausted, try to get the next one delete fIter2; - fIter2 = 0x0; - AliMpExMap* m(0x0); - while ( !m && fCurrentI < fLastI ) - { - ++fCurrentI; - m = static_cast(fkMap->GetValue(fCurrentI)); - } - if (!m) return 0x0; // we are done - fIter2 = new TExMapIter(m->GetIterator()); - o = GetValue(*fIter2,fCurrentJ); - } + fIter2 = NextIterator(); + return Next(); + } return o; } @@ -165,19 +116,10 @@ void AliMUON2DMapIteratorByI::Reset() { /// rewind the iterator - delete fIter2; - fIter2 = 0x0; - fCurrentI = fFirstI; - AliMpExMap* m; - - while ( !( m = static_cast(fkMap->GetValue(fCurrentI) ) ) && - fCurrentI < fLastI ) - { - ++fCurrentI; - } - if ( m ) - { - fIter2 = new TExMapIter(m->GetIterator()); - } + delete fIter2; + fIter1->Reset(); + fIter2 = NextIterator(); + fCurrentI = -1; } +