]>
Commit | Line | Data |
---|---|---|
f246123b | 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 | #include "AliMUON2DMapIterator.h" | |
f246123b | 19 | |
3d1463c8 | 20 | //----------------------------------------------------------------------------- |
f246123b | 21 | /// \class AliMUON2DMapIterator |
cb6388d5 | 22 | /// Implementation of TIterator for 2Dmaps |
f246123b | 23 | /// |
24 | /// A simple implementation of VDataIterator for 2Dmaps. | |
25 | /// | |
26 | /// \author Laurent Aphecetche | |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
f246123b | 28 | |
cb6388d5 | 29 | #include "AliMpExMap.h" |
30 | ||
f246123b | 31 | /// \cond CLASSIMP |
32 | ClassImp(AliMUON2DMapIterator) | |
33 | /// \endcond | |
34 | ||
35 | //_____________________________________________________________________________ | |
7332f213 | 36 | AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap) |
37 | : TIterator(), | |
38 | fkMap(&theMap), | |
47a48067 | 39 | fCurrentMap(0x0), |
40 | fI(-1), | |
41 | fJ(-1) | |
f246123b | 42 | { |
c4ee792d | 43 | /// default ctor |
f246123b | 44 | Reset(); |
45 | } | |
46 | ||
cb6388d5 | 47 | //_____________________________________________________________________________ |
48 | AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMUON2DMapIterator& rhs) | |
49 | : TIterator(rhs), | |
7332f213 | 50 | fkMap(rhs.fkMap), |
47a48067 | 51 | fCurrentMap(rhs.fCurrentMap), |
52 | fI(rhs.fI), | |
53 | fJ(rhs.fI) | |
cb6388d5 | 54 | { |
55 | /// copy ctor | |
cb6388d5 | 56 | } |
47a48067 | 57 | |
cb6388d5 | 58 | //_____________________________________________________________________________ |
59 | AliMUON2DMapIterator& | |
60 | AliMUON2DMapIterator::operator=(const AliMUON2DMapIterator& rhs) | |
61 | { | |
62 | /// assignment operator | |
63 | if ( this != &rhs ) | |
64 | { | |
7332f213 | 65 | fkMap = rhs.fkMap; |
47a48067 | 66 | fCurrentMap = rhs.fCurrentMap; |
67 | fI = rhs.fI; | |
68 | fJ = rhs.fJ; | |
cb6388d5 | 69 | } |
70 | return *this; | |
71 | } | |
72 | ||
73 | //_____________________________________________________________________________ | |
74 | TIterator& | |
75 | AliMUON2DMapIterator::operator=(const TIterator& rhs) | |
76 | { | |
77 | /// overriden operator= (imposed by Root's definition of TIterator::operator= ?) | |
78 | ||
79 | if ( this != &rhs && rhs.IsA() == AliMUON2DMapIterator::Class() ) | |
80 | { | |
81 | const AliMUON2DMapIterator& rhs1 = static_cast<const AliMUON2DMapIterator&>(rhs); | |
7332f213 | 82 | fkMap = rhs1.fkMap; |
47a48067 | 83 | fCurrentMap = rhs1.fCurrentMap; |
84 | fI = rhs1.fI; | |
85 | fJ = rhs1.fJ; | |
cb6388d5 | 86 | } |
87 | return *this; | |
88 | } | |
89 | ||
f246123b | 90 | //_____________________________________________________________________________ |
91 | AliMUON2DMapIterator::~AliMUON2DMapIterator() | |
92 | { | |
c4ee792d | 93 | /// dtor |
f246123b | 94 | } |
95 | ||
cb6388d5 | 96 | //_____________________________________________________________________________ |
97 | const TCollection* | |
98 | AliMUON2DMapIterator::GetCollection() const | |
99 | { | |
100 | /// Return 0 as we're not really dealing with a Root TCollection... | |
101 | return 0x0; | |
102 | } | |
103 | ||
f246123b | 104 | //_____________________________________________________________________________ |
105 | AliMpExMap* | |
47a48067 | 106 | AliMUON2DMapIterator::Map(Int_t i) const |
f246123b | 107 | { |
47a48067 | 108 | /// Get the map at a given index |
7332f213 | 109 | return static_cast<AliMpExMap*>(fkMap->GetObjectFast(i)); |
f246123b | 110 | } |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | TObject* | |
114 | AliMUON2DMapIterator::Next() | |
115 | { | |
47a48067 | 116 | /// return next object |
117 | ||
118 | if (!fCurrentMap) return 0x0; | |
f246123b | 119 | |
47a48067 | 120 | ++fJ; |
f246123b | 121 | |
47a48067 | 122 | if ( fJ < fCurrentMap->GetSize() ) |
123 | { | |
124 | return fCurrentMap->GetObjectFast(fJ); | |
125 | } | |
126 | else | |
f246123b | 127 | { |
47a48067 | 128 | ++fI; |
7332f213 | 129 | if ( fI < fkMap->GetSize() ) |
f246123b | 130 | { |
47a48067 | 131 | fCurrentMap = Map(fI); |
132 | fJ = -1; | |
133 | return Next(); | |
f246123b | 134 | } |
47a48067 | 135 | return 0x0; |
cb6388d5 | 136 | } |
f246123b | 137 | } |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | void | |
141 | AliMUON2DMapIterator::Reset() | |
142 | { | |
c4ee792d | 143 | /// rewind the iterator |
47a48067 | 144 | fI = -1; |
145 | fJ = -1; | |
146 | fCurrentMap = 0x0; | |
147 | ||
7332f213 | 148 | if ( fkMap->GetSize() > 0 ) |
f246123b | 149 | { |
47a48067 | 150 | fI = 0; |
151 | fCurrentMap = Map(fI); | |
152 | fJ = -1; | |
153 | } | |
f246123b | 154 | } |
47a48067 | 155 |