X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=MUON%2FAliMUON2DMapIterator.cxx;h=2bb027ec51110c7c0fd62ff4cc965d7fd99153fb;hp=507b82f80e02bcb71d87a3cf8038dee6666d5b56;hb=52a564eeeed3ad431eba15a08cfc0a5f4594e891;hpb=f246123b1321692dcd7ef8aa12c6cab84e911cf4 diff --git a/MUON/AliMUON2DMapIterator.cxx b/MUON/AliMUON2DMapIterator.cxx index 507b82f80e0..2bb027ec511 100644 --- a/MUON/AliMUON2DMapIterator.cxx +++ b/MUON/AliMUON2DMapIterator.cxx @@ -16,118 +16,102 @@ // $Id$ #include "AliMUON2DMapIterator.h" -#include "AliMpExMap.h" -#include "TMap.h" -#include "AliLog.h" -#include "AliMpIntPair.h" +//----------------------------------------------------------------------------- /// \class AliMUON2DMapIterator -/// \brief Implementation of AliMUONVDataIterator for 2Dmaps +/// Implementation of TIterator for 2Dmaps /// /// A simple implementation of VDataIterator for 2Dmaps. /// /// \author Laurent Aphecetche +//----------------------------------------------------------------------------- + +#include "AliMpExMap.h" +#include "AliMpExMapIterator.h" +#include "AliLog.h" /// \cond CLASSIMP ClassImp(AliMUON2DMapIterator) /// \endcond //_____________________________________________________________________________ -AliMUON2DMapIterator::AliMUON2DMapIterator(AliMpExMap& theMap) -: AliMUONVDataIterator(), -fIter(theMap.GetIterator()), -fIter2(0x0), -fCurrentI(-1), -fCurrentJ(-1) +AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap) +: TIterator(), +fkMap(&theMap), +fIter1(theMap.CreateIterator()), +fIter2(NextIterator()) { - // default ctor + /// default ctor Reset(); } +//_____________________________________________________________________________ +AliMUON2DMapIterator& +AliMUON2DMapIterator::operator=(const TIterator& /*rhs*/) +{ + // overriden operator= (imposed by Root's definition of TIterator::operator= ?) + + AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor + return *this; +} + //_____________________________________________________________________________ AliMUON2DMapIterator::~AliMUON2DMapIterator() { - // dtor + /// dtor + delete fIter1; delete fIter2; } //_____________________________________________________________________________ -TObject* -AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const +const TCollection* +AliMUON2DMapIterator::GetCollection() const { - // 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); + /// Return 0 as we're not really dealing with a Root TCollection... + return 0x0; } //_____________________________________________________________________________ -AliMpExMap* -AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key) +TIterator* +AliMUON2DMapIterator::NextIterator() { - // get the map corresponding to key - AliMpExMap* rv(0x0); - TObject* o = GetValue(iter,key); - if (o) - { - rv = dynamic_cast(o); - if (!rv) - { - AliFatal("boom"); - } - } - return rv; + /// Get next map (from fIter1) and create an iterator to it + + AliMpExMap* m = static_cast(fIter1->Next()); + + 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 new TPair(new AliMpIntPair(fCurrentI,fCurrentJ),o); + + return o; } //_____________________________________________________________________________ void AliMUON2DMapIterator::Reset() { - // rewind the iterator + /// rewind the iterator + delete fIter2; - fIter.Reset(); - AliMpExMap* m = GetMap(fIter,fCurrentI); - if (m) - { - fIter2 = new TExMapIter(m->GetIterator()); - } + fIter1->Reset(); + fIter2 = NextIterator(); } -//_____________________________________________________________________________ -Bool_t -AliMUON2DMapIterator::Remove() -{ - // to be implemented if needed - AliInfo("Not supported yet"); - return kFALSE; -}