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 //-----------------------------------------------------------------------------
21 /// \class AliMUON2DMapIterator
22 /// Implementation of TIterator for 2Dmaps
24 /// A simple implementation of VDataIterator for 2Dmaps.
26 /// \author Laurent Aphecetche
27 //-----------------------------------------------------------------------------
29 #include "AliMpExMap.h"
32 ClassImp(AliMUON2DMapIterator)
35 //_____________________________________________________________________________
36 AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap)
38 fIter(theMap.GetIterator()),
47 //_____________________________________________________________________________
48 AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMUON2DMapIterator& rhs)
52 fCurrentI(rhs.fCurrentI),
53 fCurrentJ(rhs.fCurrentJ)
56 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2);
59 //_____________________________________________________________________________
61 AliMUON2DMapIterator::operator=(const AliMUON2DMapIterator& rhs)
63 /// assignment operator
68 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*rhs.fIter2);
69 fCurrentI = rhs.fCurrentI;
70 fCurrentJ = rhs.fCurrentJ;
75 //_____________________________________________________________________________
77 AliMUON2DMapIterator::operator=(const TIterator& rhs)
79 /// overriden operator= (imposed by Root's definition of TIterator::operator= ?)
81 if ( this != &rhs && rhs.IsA() == AliMUON2DMapIterator::Class() )
83 const AliMUON2DMapIterator& rhs1 = static_cast<const AliMUON2DMapIterator&>(rhs);
87 if ( rhs1.fIter2 ) fIter2 = new TExMapIter(*rhs1.fIter2);
88 fCurrentI = rhs1.fCurrentI;
89 fCurrentJ = rhs1.fCurrentJ;
94 //_____________________________________________________________________________
95 AliMUON2DMapIterator::~AliMUON2DMapIterator()
101 //_____________________________________________________________________________
103 AliMUON2DMapIterator::GetCollection() const
105 /// Return 0 as we're not really dealing with a Root TCollection...
109 //_____________________________________________________________________________
111 AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const
113 /// return the value corresponding to theKey in iterator iter
116 Bool_t ok = iter.Next(key,value);
118 theKey = (Int_t)(key & 0xFFFF);
119 return reinterpret_cast<TObject*>(value);
122 //_____________________________________________________________________________
124 AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key) const
126 /// get the map corresponding to key
128 TObject* o = GetValue(iter,key);
131 rv = dynamic_cast<AliMpExMap*>(o);
136 //_____________________________________________________________________________
138 AliMUON2DMapIterator::Next()
141 /// get TObject* from fIter2
142 /// if null, increment fIter2 by getting next on fIter
144 if (!fIter2) return 0x0;
146 TObject* o = GetValue(*fIter2,fCurrentJ);
149 // fIter2 exhausted, try to get the next one
150 AliMpExMap* m = GetMap(fIter,fCurrentI);
153 // nothing left, we are done.
157 fIter2 = new TExMapIter(m->GetIterator());
158 o = GetValue(*fIter2,fCurrentJ);
164 //_____________________________________________________________________________
166 AliMUON2DMapIterator::Reset()
168 /// rewind the iterator
171 AliMpExMap* m = GetMap(fIter,fCurrentI);
174 fIter2 = new TExMapIter(m->GetIterator());