]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON1DMap.cxx
correction of trivial typo preventing compilation
[u/mrichter/AliRoot.git] / MUON / AliMUON1DMap.cxx
CommitLineData
83c386fb 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 "AliMUON1DMap.h"
7332f213 19#include "AliMUON1DMapIterator.h"
20#include "AliMpExMap.h"
83c386fb 21
22#include "AliLog.h"
83c386fb 23
3d1463c8 24//-----------------------------------------------------------------------------
83c386fb 25/// \class AliMUON1DMap
26/// This class is simply a wrapper to an AliMpExMap, offering in addition a
27/// control over the replacement policy when you add
28/// something to it.
29///
30/// \author Laurent Aphecetche
3d1463c8 31//-----------------------------------------------------------------------------
83c386fb 32
33/// \cond CLASSIMP
34ClassImp(AliMUON1DMap)
35/// \endcond
36
37//_____________________________________________________________________________
38AliMUON1DMap::AliMUON1DMap(Int_t theSize)
4178b5c7 39: AliMUONVStore(),
7332f213 40 fMap(new AliMpExMap(kTRUE))
83c386fb 41{
42/// Default ctor
43
44 if ( theSize )
45 {
46 fMap->SetSize(theSize);
47 }
48 fMap->SetOwner(kTRUE);
49}
50
51//_____________________________________________________________________________
52AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
4178b5c7 53: AliMUONVStore(),
7332f213 54 fMap(new AliMpExMap(*other.fMap))
83c386fb 55{
56/// Copy constructor
83c386fb 57}
58
59//_____________________________________________________________________________
60AliMUON1DMap&
61AliMUON1DMap::operator=(const AliMUON1DMap& other)
62{
63/// Assignment operator
7332f213 64 *fMap = *other.fMap;
83c386fb 65 return *this;
66}
67
68//_____________________________________________________________________________
69AliMUON1DMap::~AliMUON1DMap()
70{
7332f213 71/// destructor
83c386fb 72 delete fMap;
73}
74
4178b5c7 75//_____________________________________________________________________________
76Bool_t
77AliMUON1DMap::Add(TObject* object)
78{
79 /// Add an object to this, using uniqueID as the key
80 if (!object) return kFALSE;
7332f213 81 return Set(object->GetUniqueID(),object);
4178b5c7 82}
83
84//_____________________________________________________________________________
85void
86AliMUON1DMap::Clear(Option_t*)
87{
88 /// Reset
7332f213 89 fMap->Clear();
83c386fb 90}
91
4178b5c7 92//_____________________________________________________________________________
93AliMUON1DMap*
94AliMUON1DMap::Create() const
95{
96 /// Create an empty clone of this
97 return new AliMUON1DMap(fMap->GetSize());
98}
99
83c386fb 100//_____________________________________________________________________________
101TObject*
4178b5c7 102AliMUON1DMap::FindObject(UInt_t i) const
83c386fb 103{
104/// Get the object located at index i, if it exists, and if i is correct.
83c386fb 105 return fMap->GetValue(i);
106}
107
49419555 108//_____________________________________________________________________________
109TObject*
110AliMUON1DMap::FindObject(Int_t i, Int_t j) const
111{
112 /// Get the object located at index (i,j), if it exists, and if i,j is correct.
113
114 UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
115
116 return fMap->GetValue(uid);
117}
118
83c386fb 119//_____________________________________________________________________________
4178b5c7 120TIterator*
121AliMUON1DMap::CreateIterator() const
83c386fb 122{
7332f213 123 /// Create and return an iterator on this map
124 /// Returned iterator must be deleted by user.
125 return new AliMUON1DMapIterator(*fMap);
83c386fb 126}
127
4178b5c7 128//_____________________________________________________________________________
129Int_t
130AliMUON1DMap::GetSize() const
131{
132 /// Return the number of objects we hold
133 return fMap->GetSize();
134}
83c386fb 135
136//_____________________________________________________________________________
137Bool_t
7332f213 138AliMUON1DMap::Set(Int_t i, TObject* object)
83c386fb 139{
140/// Set the object located at i
7332f213 141/// If there's already an object at location i,
83c386fb 142/// this method fails and returns kFALSE, otherwise it returns kTRUE
7332f213 143
4178b5c7 144 TObject* o = FindObject(i);
7332f213 145 if ( o )
83c386fb 146 {
147 AliError(Form("Object %p is already there for i=%d",o,i));
148 return kFALSE;
149 }
83c386fb 150 fMap->Add(i,object);
151 return kTRUE;
152}
153