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 "AliMUON1DMapIterator.h"
20 #include "AliMpExMap.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(Int_t theSize)
40 fMap(new AliMpExMap(kTRUE))
46 fMap->SetSize(theSize);
48 fMap->SetOwner(kTRUE);
51 //_____________________________________________________________________________
52 AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
54 fMap(new AliMpExMap(*other.fMap))
59 //_____________________________________________________________________________
61 AliMUON1DMap::operator=(const AliMUON1DMap& other)
63 /// Assignment operator
68 //_____________________________________________________________________________
69 AliMUON1DMap::~AliMUON1DMap()
75 //_____________________________________________________________________________
77 AliMUON1DMap::Add(TObject* object)
79 /// Add an object to this, using uniqueID as the key
80 if (!object) return kFALSE;
81 return Set(object->GetUniqueID(),object);
84 //_____________________________________________________________________________
86 AliMUON1DMap::Clear(Option_t*)
92 //_____________________________________________________________________________
94 AliMUON1DMap::Create() const
96 /// Create an empty clone of this
97 return new AliMUON1DMap(fMap->GetSize());
100 //_____________________________________________________________________________
102 AliMUON1DMap::FindObject(UInt_t i) const
104 /// Get the object located at index i, if it exists, and if i is correct.
105 return fMap->GetValue(i);
108 //_____________________________________________________________________________
110 AliMUON1DMap::FindObject(Int_t i, Int_t j) const
112 /// Get the object located at index (i,j), if it exists, and if i,j is correct.
114 UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
116 return fMap->GetValue(uid);
119 //_____________________________________________________________________________
121 AliMUON1DMap::CreateIterator() const
123 /// Create and return an iterator on this map
124 /// Returned iterator must be deleted by user.
125 return new AliMUON1DMapIterator(*fMap);
128 //_____________________________________________________________________________
130 AliMUON1DMap::GetSize() const
132 /// Return the number of objects we hold
133 return fMap->GetSize();
136 //_____________________________________________________________________________
138 AliMUON1DMap::Set(Int_t i, TObject* object)
140 /// Set the object located at i
141 /// If there's already an object at location i,
142 /// this method fails and returns kFALSE, otherwise it returns kTRUE
144 TObject* o = FindObject(i);
147 AliError(Form("Object %p is already there for i=%d",o,i));