X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUON2DMapIterator.cxx;h=a95de14b9f35b124f11c3af60f923de2f1ebcc0a;hb=57acd2d2f484e474d764cf49c17bf8a0af5bdd5e;hp=7ffffcfd447ca5c12e8907f8083c48dbf6829082;hpb=3d1463c8f7148e36069c24f20cde34e096d5d6a9;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUON2DMapIterator.cxx b/MUON/AliMUON2DMapIterator.cxx index 7ffffcfd447..a95de14b9f3 100644 --- a/MUON/AliMUON2DMapIterator.cxx +++ b/MUON/AliMUON2DMapIterator.cxx @@ -27,6 +27,8 @@ //----------------------------------------------------------------------------- #include "AliMpExMap.h" +#include "AliMpExMapIterator.h" +#include "AliLog.h" /// \cond CLASSIMP ClassImp(AliMUON2DMapIterator) @@ -34,60 +36,22 @@ ClassImp(AliMUON2DMapIterator) //_____________________________________________________________________________ AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap) -: TIterator(), -fIter(theMap.GetIterator()), -fIter2(0x0), -fCurrentI(-1), -fCurrentJ(-1) +: TIterator(), +fkMap(&theMap), +fIter1(theMap.CreateIterator()), +fIter2(NextIterator()) { /// default ctor Reset(); } -//_____________________________________________________________________________ -AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMUON2DMapIterator& rhs) -: TIterator(rhs), -fIter(rhs.fIter), -fIter2(0x0), -fCurrentI(rhs.fCurrentI), -fCurrentJ(rhs.fCurrentJ) -{ - /// copy ctor - if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2); - -} //_____________________________________________________________________________ AliMUON2DMapIterator& -AliMUON2DMapIterator::operator=(const AliMUON2DMapIterator& rhs) +AliMUON2DMapIterator::operator=(const TIterator& /*rhs*/) { - /// assignment operator - if ( this != &rhs ) - { - fIter = rhs.fIter; - fIter2 = 0x0; - if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2); - fCurrentI = rhs.fCurrentI; - fCurrentJ = rhs.fCurrentJ; - } - return *this; -} - -//_____________________________________________________________________________ -TIterator& -AliMUON2DMapIterator::operator=(const TIterator& rhs) -{ - /// overriden operator= (imposed by Root's definition of TIterator::operator= ?) + // overriden operator= (imposed by Root's definition of TIterator::operator= ?) - if ( this != &rhs && rhs.IsA() == AliMUON2DMapIterator::Class() ) - { - const AliMUON2DMapIterator& rhs1 = static_cast(rhs); - - fIter = rhs1.fIter; - fIter2 = 0x0; - if ( rhs1.fIter2 ) fIter2 = new TExMapIter(*rhs1.fIter2); - fCurrentI = rhs1.fCurrentI; - fCurrentJ = rhs1.fCurrentJ; - } + AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor return *this; } @@ -95,7 +59,6 @@ AliMUON2DMapIterator::operator=(const TIterator& rhs) AliMUON2DMapIterator::~AliMUON2DMapIterator() { /// dtor - delete fIter2; } //_____________________________________________________________________________ @@ -107,55 +70,32 @@ AliMUON2DMapIterator::GetCollection() const } //_____________________________________________________________________________ -TObject* -AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const +TIterator* +AliMUON2DMapIterator::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()); -//_____________________________________________________________________________ -AliMpExMap* -AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key) const -{ - /// get the map corresponding to key - AliMpExMap* rv(0x0); - TObject* o = GetValue(iter,key); - if (o) - { - rv = dynamic_cast(o); - } - return rv; + if (!m) return 0x0; + + return m->CreateIterator(); } //_____________________________________________________________________________ TObject* AliMUON2DMapIterator::Next() { - /// logic : - /// get TObject* from fIter2 - /// if null, increment fIter2 by getting next on fIter + /// return next object if (!fIter2) return 0x0; + + TObject* o = fIter2->Next(); - TObject* o = GetValue(*fIter2,fCurrentJ); if (!o) { - // fIter2 exhausted, try to get the next one - AliMpExMap* m = GetMap(fIter,fCurrentI); - if (!m) - { - // nothing left, we are done. - return 0x0; - } - delete fIter2; - fIter2 = new TExMapIter(m->GetIterator()); - o = GetValue(*fIter2,fCurrentJ); + fIter2 = NextIterator(); + return Next(); } return o; @@ -166,11 +106,9 @@ void AliMUON2DMapIterator::Reset() { /// rewind the iterator + delete fIter2; - fIter.Reset(); - AliMpExMap* m = GetMap(fIter,fCurrentI); - if (m) - { - fIter2 = new TExMapIter(m->GetIterator()); - } + fIter1->Reset(); + fIter2 = NextIterator(); } +