1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliMUON2DMapIterator.h"
20 /// \class AliMUON2DMapIterator
21 /// Implementation of TIterator for 2Dmaps
23 /// A simple implementation of VDataIterator for 2Dmaps.
25 /// \author Laurent Aphecetche
27 #include "AliMpExMap.h"
30 ClassImp(AliMUON2DMapIterator)
33 //_____________________________________________________________________________
34 AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap)
36 fIter(theMap.GetIterator()),
45 //_____________________________________________________________________________
46 AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMUON2DMapIterator& rhs)
50 fCurrentI(rhs.fCurrentI),
51 fCurrentJ(rhs.fCurrentJ)
54 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2);
57 //_____________________________________________________________________________
59 AliMUON2DMapIterator::operator=(const AliMUON2DMapIterator& rhs)
61 /// assignment operator
66 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2);
67 fCurrentI = rhs.fCurrentI;
68 fCurrentJ = rhs.fCurrentJ;
73 //_____________________________________________________________________________
75 AliMUON2DMapIterator::operator=(const TIterator& rhs)
77 /// overriden operator= (imposed by Root's definition of TIterator::operator= ?)
79 if ( this != &rhs && rhs.IsA() == AliMUON2DMapIterator::Class() )
81 const AliMUON2DMapIterator& rhs1 = static_cast<const AliMUON2DMapIterator&>(rhs);
85 if ( rhs1.fIter2 ) fIter2 = new TExMapIter(*rhs1.fIter2);
86 fCurrentI = rhs1.fCurrentI;
87 fCurrentJ = rhs1.fCurrentJ;
92 //_____________________________________________________________________________
93 AliMUON2DMapIterator::~AliMUON2DMapIterator()
99 //_____________________________________________________________________________
101 AliMUON2DMapIterator::GetCollection() const
103 /// Return 0 as we're not really dealing with a Root TCollection...
107 //_____________________________________________________________________________
109 AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const
111 /// return the value corresponding to theKey in iterator iter
114 Bool_t ok = iter.Next(key,value);
116 theKey = (Int_t)(key & 0xFFFF);
117 return reinterpret_cast<TObject*>(value);
120 //_____________________________________________________________________________
122 AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key) const
124 /// get the map corresponding to key
126 TObject* o = GetValue(iter,key);
129 rv = dynamic_cast<AliMpExMap*>(o);
134 //_____________________________________________________________________________
136 AliMUON2DMapIterator::Next()
139 /// get TObject* from fIter2
140 /// if null, increment fIter2 by getting next on fIter
142 if (!fIter2) return 0x0;
144 TObject* o = GetValue(*fIter2,fCurrentJ);
147 // fIter2 exhausted, try to get the next one
148 AliMpExMap* m = GetMap(fIter,fCurrentI);
151 // nothing left, we are done.
155 fIter2 = new TExMapIter(m->GetIterator());
156 o = GetValue(*fIter2,fCurrentJ);
162 //_____________________________________________________________________________
164 AliMUON2DMapIterator::Reset()
166 /// rewind the iterator
169 AliMpExMap* m = GetMap(fIter,fCurrentI);
172 fIter2 = new TExMapIter(m->GetIterator());