Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
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 : **************************************************************************/
15 :
16 : // $Id$
17 :
18 : //-----------------------------------------------------------------------------
19 : /// \class AliMUON2DMapIteratorByI
20 : ///
21 : /// Implementation of TIterator for 2D maps
22 : ///
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).
26 : ///
27 : /// \author Laurent Aphecetche
28 : //-----------------------------------------------------------------------------
29 :
30 : #include "AliMUON2DMapIteratorByI.h"
31 : #include "AliMpExMapIterator.h"
32 : #include "AliMpExMap.h"
33 : #include "AliLog.h"
34 :
35 : /// \cond CLASSIMP
36 18 : ClassImp(AliMUON2DMapIteratorByI)
37 : /// \endcond
38 :
39 : //_____________________________________________________________________________
40 : AliMUON2DMapIteratorByI::AliMUON2DMapIteratorByI(const AliMpExMap& theMap, Int_t firstI, Int_t lastI)
41 961 : : TIterator(),
42 961 : fkMap(&theMap),
43 1922 : fIter1(theMap.CreateIterator()),
44 961 : fIter2(0x0),
45 961 : fFirstI(firstI),
46 961 : fLastI(lastI),
47 961 : fCurrentI(-1)
48 4805 : {
49 : /// default ctor
50 961 : Reset();
51 1922 : }
52 :
53 : //_____________________________________________________________________________
54 : AliMUON2DMapIteratorByI&
55 : AliMUON2DMapIteratorByI::operator=(const TIterator& /*rhs*/)
56 : {
57 : // overriden operator= (imposed by Root's definition of TIterator::operator= ?)
58 :
59 0 : AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor
60 0 : return *this;
61 : }
62 :
63 : //_____________________________________________________________________________
64 : AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI()
65 5766 : {
66 : /// dtor
67 1922 : delete fIter1;
68 961 : delete fIter2;
69 2883 : }
70 :
71 : //_____________________________________________________________________________
72 : const TCollection*
73 : AliMUON2DMapIteratorByI::GetCollection() const
74 : {
75 : /// Return 0 as we're not really dealing with a Root TCollection...
76 0 : return 0x0;
77 : }
78 :
79 : //_____________________________________________________________________________
80 : AliMpExMapIterator*
81 : AliMUON2DMapIteratorByI::NextIterator()
82 : {
83 : /// Get next map (from fIter1) and create an iterator to it
84 :
85 15170 : AliMpExMap* m = static_cast<AliMpExMap*>(fIter1->Next(fCurrentI));
86 :
87 8546 : if (!m) return 0x0;
88 :
89 13344 : if ( fCurrentI < fFirstI || fCurrentI > fLastI ) return NextIterator(); // try again
90 :
91 4232 : return m->CreateIterator();
92 7585 : }
93 :
94 : //_____________________________________________________________________________
95 : TObject*
96 : AliMUON2DMapIteratorByI::Next()
97 : {
98 : /// return next object
99 :
100 36947 : if (!fIter2) return 0x0;
101 :
102 17032 : TObject* o = fIter2->Next();
103 :
104 17032 : if (!o)
105 : {
106 8464 : delete fIter2;
107 4232 : fIter2 = NextIterator();
108 4232 : return Next();
109 : }
110 :
111 12800 : return o;
112 17993 : }
113 :
114 : //_____________________________________________________________________________
115 : void
116 : AliMUON2DMapIteratorByI::Reset()
117 : {
118 : /// rewind the iterator
119 :
120 1922 : delete fIter2;
121 961 : fIter1->Reset();
122 961 : fIter2 = NextIterator();
123 961 : fCurrentI = -1;
124 961 : }
125 :
|