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"
21 #include "AliMpExMap.h"
22 #include "AliMUON1DMapIterator.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(true))
46 fMap->SetSize(theSize);
48 fMap->SetOwner(kTRUE);
51 //_____________________________________________________________________________
52 AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
61 //_____________________________________________________________________________
63 AliMUON1DMap::operator=(const AliMUON1DMap& other)
65 /// Assignment operator
71 //_____________________________________________________________________________
72 AliMUON1DMap::~AliMUON1DMap()
74 /// dtor, we're the owner of our internal map.
79 //_____________________________________________________________________________
81 AliMUON1DMap::Add(TObject* object)
83 /// Add an object to this, using uniqueID as the key
84 if (!object) return kFALSE;
85 Set(object->GetUniqueID(),object,kFALSE);
89 //_____________________________________________________________________________
91 AliMUON1DMap::Clear(Option_t*)
98 //_____________________________________________________________________________
100 AliMUON1DMap::CopyTo(AliMUON1DMap& dest) const
108 //_____________________________________________________________________________
110 AliMUON1DMap::Create() const
112 /// Create an empty clone of this
113 return new AliMUON1DMap(fMap->GetSize());
116 //_____________________________________________________________________________
118 AliMUON1DMap::FindObject(UInt_t i) const
120 /// Get the object located at index i, if it exists, and if i is correct.
122 return fMap->GetValue(i);
125 //_____________________________________________________________________________
127 AliMUON1DMap::CreateIterator() const
129 // Create and return an iterator on this map
130 // Returned iterator must be deleted by user.
133 return new AliMUON1DMapIterator(*fMap);
138 //_____________________________________________________________________________
140 AliMUON1DMap::GetSize() const
142 /// Return the number of objects we hold
143 return fMap->GetSize();
146 //_____________________________________________________________________________
148 AliMUON1DMap::Set(Int_t i, TObject* object, Bool_t replace)
150 /// Set the object located at i
151 /// If replace=kFALSE and there's already an object at location i,
152 /// this method fails and returns kFALSE, otherwise it returns kTRUE
154 TObject* o = FindObject(i);
157 AliError(Form("Object %p is already there for i=%d",o,i));