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 //-----------------------------------------------------------------------------
19 /// \class AliMUON2DMapIteratorByI
21 /// Implementation of TIterator for 2D maps
23 /// An implementation of TIterator for 2D maps, which can iterate
24 /// on a range of i values (i being the first element of the couple
25 /// (i,j) used to index values in the map).
27 /// \author Laurent Aphecetche
28 //-----------------------------------------------------------------------------
30 #include "AliMUON2DMapIteratorByI.h"
32 #include "AliMpExMap.h"
35 ClassImp(AliMUON2DMapIteratorByI)
38 //_____________________________________________________________________________
39 AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMpExMap& theMap,
54 //_____________________________________________________________________________
55 AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMUON2DMapIteratorByI& rhs)
59 fCurrentI(rhs.fCurrentI),
60 fCurrentJ(rhs.fCurrentJ),
65 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*(rhs.fIter2));
68 //_____________________________________________________________________________
69 AliMUON2DMapIteratorByI&
70 AliMUON2DMapIteratorByI::operator=(const AliMUON2DMapIteratorByI& rhs)
72 /// assignment operator
77 if ( rhs.fIter2 ) fIter2 = new TExMapIter(*(rhs.fIter2));
78 fCurrentI = rhs.fCurrentI;
79 fCurrentJ = rhs.fCurrentJ;
80 fFirstI = rhs.fFirstI;
86 //_____________________________________________________________________________
88 AliMUON2DMapIteratorByI::operator=(const TIterator& rhs)
90 /// overriden assigment operator (imposed by Root's declaration of TIterator ?)
93 const AliMUON2DMapIteratorByI& rhs1 = static_cast<const AliMUON2DMapIteratorByI&>(rhs);
96 if ( rhs1.fIter2 ) fIter2 = new TExMapIter(*(rhs1.fIter2));
97 fCurrentI = rhs1.fCurrentI;
98 fCurrentJ = rhs1.fCurrentJ;
99 fFirstI = rhs1.fFirstI;
100 fLastI = rhs1.fLastI;
105 //_____________________________________________________________________________
106 AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI()
112 //_____________________________________________________________________________
114 AliMUON2DMapIteratorByI::GetCollection() const
120 //_____________________________________________________________________________
122 AliMUON2DMapIteratorByI::GetValue(TExMapIter& iter, Int_t& theKey) const
124 /// return the value corresponding to theKey in iterator iter
127 Bool_t ok = iter.Next(key,value);
129 theKey = (Int_t)(key & 0xFFFF);
130 return reinterpret_cast<TObject*>(value);
133 //_____________________________________________________________________________
135 AliMUON2DMapIteratorByI::Next()
138 /// get TObject* from fIter2
139 /// if null, increment fIter2 by getting next map from fMap
141 if (!fIter2) return 0x0;
143 TObject* o = GetValue(*fIter2,fCurrentJ);
146 // fIter2 exhausted, try to get the next one
150 while ( !m && fCurrentI < fLastI )
153 m = static_cast<AliMpExMap*>(fMap->GetValue(fCurrentI));
155 if (!m) return 0x0; // we are done
156 fIter2 = new TExMapIter(m->GetIterator());
157 o = GetValue(*fIter2,fCurrentJ);
163 //_____________________________________________________________________________
165 AliMUON2DMapIteratorByI::Reset()
167 /// rewind the iterator
173 while ( !( m = static_cast<AliMpExMap*>(fMap->GetValue(fCurrentI) ) ) &&
181 fIter2 = new TExMapIter(m->GetIterator());