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"
23 #include "AliMUONObjectPair.h"
25 /// \class AliMUON2DMapIterator
26 /// \brief Implementation of AliMUONVDataIterator for 2Dmaps
28 /// A simple implementation of VDataIterator for 2Dmaps.
30 /// \author Laurent Aphecetche
33 ClassImp(AliMUON2DMapIterator)
36 //_____________________________________________________________________________
37 AliMUON2DMapIterator::AliMUON2DMapIterator(AliMpExMap& theMap)
38 : AliMUONVDataIterator(),
39 fIter(theMap.GetIterator()),
48 //_____________________________________________________________________________
49 AliMUON2DMapIterator::~AliMUON2DMapIterator()
55 //_____________________________________________________________________________
57 AliMUON2DMapIterator::GetValue(TExMapIter& iter, Int_t& theKey) const
59 // return the value corresponding to theKey in iterator iter
62 Bool_t ok = iter.Next(key,value);
64 theKey = (Int_t)(key & 0xFFFF);
65 return reinterpret_cast<TObject*>(value);
68 //_____________________________________________________________________________
70 AliMUON2DMapIterator::GetMap(TExMapIter& iter, Int_t& key)
72 // get the map corresponding to key
74 TObject* o = GetValue(iter,key);
77 rv = dynamic_cast<AliMpExMap*>(o);
86 //_____________________________________________________________________________
88 AliMUON2DMapIterator::Next()
91 // get TObject* from fIter2
92 // if null, increment fIter2 by getting next on fIter
94 if (!fIter2) return 0x0;
96 TObject* o = GetValue(*fIter2,fCurrentJ);
99 // fIter2 exhausted, try to get the next one
100 AliMpExMap* m = GetMap(fIter,fCurrentI);
103 // nothing left, we are done.
107 fIter2 = new TExMapIter(m->GetIterator());
108 o = GetValue(*fIter2,fCurrentJ);
110 return new AliMUONObjectPair(new AliMpIntPair(fCurrentI,fCurrentJ),o,
111 kTRUE, /* owner of intpair */
112 kFALSE /* but not of o */);
115 //_____________________________________________________________________________
117 AliMUON2DMapIterator::Reset()
119 // rewind the iterator
122 AliMpExMap* m = GetMap(fIter,fCurrentI);
125 fIter2 = new TExMapIter(m->GetIterator());
129 //_____________________________________________________________________________
131 AliMUON2DMapIterator::Remove()
133 // to be implemented if needed
134 AliInfo("Not supported yet");