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 "AliMUON1DMap.h"
19 #include "AliMpExMap.h"
20 #include "AliMpExMapIterator.h"
24 //-----------------------------------------------------------------------------
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
30 /// \author Laurent Aphecetche
31 //-----------------------------------------------------------------------------
34 ClassImp(AliMUON1DMap)
37 //_____________________________________________________________________________
38 AliMUON1DMap::AliMUON1DMap(TRootIOCtor*)
46 //_____________________________________________________________________________
47 AliMUON1DMap::AliMUON1DMap(Int_t theSize)
55 fMap->SetSize(theSize);
57 fMap->SetOwner(kTRUE);
60 //_____________________________________________________________________________
61 AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
63 fMap(new AliMpExMap(*other.fMap))
68 //_____________________________________________________________________________
70 AliMUON1DMap::operator=(const AliMUON1DMap& other)
72 /// Assignment operator
77 //_____________________________________________________________________________
78 AliMUON1DMap::~AliMUON1DMap()
84 //_____________________________________________________________________________
86 AliMUON1DMap::Add(TObject* object)
88 /// Add an object to this, using uniqueID as the key
89 if (!object) return kFALSE;
90 return Set(object->GetUniqueID(),object);
93 //_____________________________________________________________________________
95 AliMUON1DMap::Clear(Option_t*)
101 //_____________________________________________________________________________
103 AliMUON1DMap::Create() const
105 /// Create an empty clone of this
106 return new AliMUON1DMap(fMap->GetSize());
109 //_____________________________________________________________________________
111 AliMUON1DMap::FindObject(UInt_t i) const
113 /// Get the object located at index i, if it exists, and if i is correct.
114 return fMap->GetValue(i);
117 //_____________________________________________________________________________
119 AliMUON1DMap::FindObject(Int_t i, Int_t j) const
121 /// Get the object located at index (i,j), if it exists, and if i,j is correct.
123 UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
125 return fMap->GetValue(uid);
128 //_____________________________________________________________________________
130 AliMUON1DMap::CreateIterator() const
132 /// Create and return an iterator on this map
133 /// Returned iterator must be deleted by user.
134 return fMap->CreateIterator();
137 //_____________________________________________________________________________
139 AliMUON1DMap::GetSize() const
141 /// Return the number of objects we hold
142 return fMap->GetSize();
145 //_____________________________________________________________________________
147 AliMUON1DMap::Set(Int_t i, TObject* object)
149 /// Set the object located at i
150 /// If there's already an object at location i,
151 /// this method fails and returns kFALSE, otherwise it returns kTRUE
153 TObject* o = FindObject(i);
156 AliError(Form("Object %p is already there for i=%d",o,i));