]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUON1DMap.cxx
Fixing part of the Coding violation
[u/mrichter/AliRoot.git] / MUON / AliMUON1DMap.cxx
index c7fb5e44bff50ee0d0768b592e7f8594cea192da..5178de6d6936ff7e96c6e5d62ca78d4f8079a850 100644 (file)
 // $Id$
 
 #include "AliMUON1DMap.h"
+#include "AliMUON1DMapIterator.h"
+#include "AliMpExMap.h"
 
 #include "AliLog.h"
-#include "AliMpExMap.h"
-#include "AliMUON1DMapIterator.h"
 
-///
+//-----------------------------------------------------------------------------
 /// \class AliMUON1DMap
 /// This class is simply a wrapper to an AliMpExMap, offering in addition a
 /// control over the replacement policy when you add
 /// something to it.
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMUON1DMap)
@@ -36,7 +37,7 @@ ClassImp(AliMUON1DMap)
 //_____________________________________________________________________________
 AliMUON1DMap::AliMUON1DMap(Int_t theSize)
 : AliMUONVStore(),
-  fMap(new AliMpExMap(true))
+  fMap(new AliMpExMap(kTRUE))
 {
 /// Default ctor
 
@@ -50,11 +51,9 @@ AliMUON1DMap::AliMUON1DMap(Int_t theSize)
 //_____________________________________________________________________________
 AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
 : AliMUONVStore(),
-  fMap(0x0)
+  fMap(new AliMpExMap(*other.fMap))
 {
 /// Copy constructor
-
-  other.CopyTo(*this);
 }
 
 //_____________________________________________________________________________
@@ -62,16 +61,14 @@ AliMUON1DMap&
 AliMUON1DMap::operator=(const AliMUON1DMap& other)
 {
 /// Assignment operator
-
-  other.CopyTo(*this);
+  *fMap = *other.fMap;
   return *this;
 }
 
 //_____________________________________________________________________________
 AliMUON1DMap::~AliMUON1DMap()
 {
-/// dtor, we're the owner of our internal map.
-
+/// destructor
   delete fMap;
 }
 
@@ -81,8 +78,7 @@ AliMUON1DMap::Add(TObject* object)
 {
   /// Add an object to this, using uniqueID as the key
   if (!object) return kFALSE;
-  Set(object->GetUniqueID(),object,kFALSE);
-  return kTRUE;
+  return Set(object->GetUniqueID(),object);
 }
 
 //_____________________________________________________________________________
@@ -90,18 +86,7 @@ void
 AliMUON1DMap::Clear(Option_t*)
 {
   /// Reset
-  delete fMap;
-  fMap = 0x0;
-}
-
-//_____________________________________________________________________________
-void
-AliMUON1DMap::CopyTo(AliMUON1DMap& dest) const
-{
-/// Make a deep copy
-
-  delete dest.fMap;
-  dest.fMap = fMap;
+  fMap->Clear();
 }
 
 //_____________________________________________________________________________
@@ -117,21 +102,27 @@ TObject*
 AliMUON1DMap::FindObject(UInt_t i) const
 {
 /// Get the object located at index i, if it exists, and if i is correct.
-
   return fMap->GetValue(i);
 }
 
+//_____________________________________________________________________________
+TObject* 
+AliMUON1DMap::FindObject(Int_t i, Int_t j) const
+{
+  /// Get the object located at index (i,j), if it exists, and if i,j is correct.
+  
+  UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
+  
+  return fMap->GetValue(uid);
+}
+
 //_____________________________________________________________________________
 TIterator*
 AliMUON1DMap::CreateIterator() const
 {
-  // Create and return an iterator on this map
-  // Returned iterator must be deleted by user.
-  if ( fMap ) 
-  {
-    return new AliMUON1DMapIterator(*fMap);
-  }
-  return 0x0;
+  /// Create and return an iterator on this map
+  /// Returned iterator must be deleted by user.
+  return new AliMUON1DMapIterator(*fMap);
 }
 
 //_____________________________________________________________________________
@@ -144,25 +135,19 @@ AliMUON1DMap::GetSize() const
 
 //_____________________________________________________________________________
 Bool_t 
-AliMUON1DMap::Set(Int_t i, TObject* object, Bool_t replace)
+AliMUON1DMap::Set(Int_t i, TObject* object)
 {
 /// Set the object located at i
-/// If replace=kFALSE and there's already an object at location i,
+/// If there's already an object at location i,
 /// this method fails and returns kFALSE, otherwise it returns kTRUE
-
+  
   TObject* o = FindObject(i);
-  if ( o && !replace )
+  if ( o )
   {
     AliError(Form("Object %p is already there for i=%d",o,i));
     return kFALSE;
   }
-  if ( replace ) 
-  {
-    delete o;
-  }
   fMap->Add(i,object);
   return kTRUE;
 }
 
-
-