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"
19 #include "AliMpExMap.h"
22 #include "AliMpIntPair.h"
24 /// \class AliMUON2DMapIterator
25 /// \brief Implementation of AliMUONVDataIterator for 2Dmaps
27 /// A simple implementation of VDataIterator for 2Dmaps.
29 /// \author Laurent Aphecetche
32 ClassImp(AliMUON2DMapIterator)
35 //_____________________________________________________________________________
36 AliMUON2DMapIterator::AliMUON2DMapIterator(AliMpExMap& theMap)
37 : AliMUONVDataIterator(),
38 fIter(theMap.GetIterator()),
47 //_____________________________________________________________________________
48 AliMUON2DMapIterator::~AliMUON2DMapIterator()
54 //_____________________________________________________________________________
56 AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const
58 // return the value corresponding to theKey in iterator iter
61 Bool_t ok = iter.Next(key,value);
63 theKey = (Int_t)(key & 0xFFFF);
64 return reinterpret_cast<TObject*>(value);
67 //_____________________________________________________________________________
69 AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key)
71 // get the map corresponding to key
73 TObject* o = GetValue(iter,key);
76 rv = dynamic_cast<AliMpExMap*>(o);
85 //_____________________________________________________________________________
87 AliMUON2DMapIterator::Next()
90 // get TObject* from fIter2
91 // if null, increment fIter2 by getting next on fIter
93 if (!fIter2) return 0x0;
95 TObject* o = GetValue(*fIter2,fCurrentJ);
98 // fIter2 exhausted, try to get the next one
99 AliMpExMap* m = GetMap(fIter,fCurrentI);
102 // nothing left, we are done.
106 fIter2 = new TExMapIter(m->GetIterator());
107 o = GetValue(*fIter2,fCurrentJ);
109 return new TPair(new AliMpIntPair(fCurrentI,fCurrentJ),o);
112 //_____________________________________________________________________________
114 AliMUON2DMapIterator::Reset()
116 // rewind the iterator
119 AliMpExMap* m = GetMap(fIter,fCurrentI);
122 fIter2 = new TExMapIter(m->GetIterator());
126 //_____________________________________________________________________________
128 AliMUON2DMapIterator::Remove()
130 // to be implemented if needed
131 AliInfo("Not supported yet");