// $Id$
#include "AliMUON1DMap.h"
+#include "AliMpExMap.h"
+#include "AliMpExMapIterator.h"
#include "AliLog.h"
-#include "AliMpExMap.h"
-#include "AliMUON1DMapIterator.h"
//-----------------------------------------------------------------------------
/// \class AliMUON1DMap
ClassImp(AliMUON1DMap)
/// \endcond
+//_____________________________________________________________________________
+AliMUON1DMap::AliMUON1DMap(TRootIOCtor*)
+: AliMUONVStore(),
+fMap(0x0)
+{
+ /// I/O ctor
+
+}
+
//_____________________________________________________________________________
AliMUON1DMap::AliMUON1DMap(Int_t theSize)
: AliMUONVStore(),
- fMap(new AliMpExMap(true))
+ fMap(new AliMpExMap)
{
/// Default ctor
- if ( theSize )
+ if ( theSize > 0)
{
fMap->SetSize(theSize);
}
- fMap->SetOwner(kTRUE);
+ fMap->SetOwner(kTRUE);
}
//_____________________________________________________________________________
AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
: AliMUONVStore(),
- fMap(0x0)
+ fMap(new AliMpExMap(*other.fMap))
{
/// Copy constructor
-
- other.CopyTo(*this);
}
//_____________________________________________________________________________
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;
}
{
/// 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);
}
//_____________________________________________________________________________
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();
}
//_____________________________________________________________________________
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 fMap->CreateIterator();
}
//_____________________________________________________________________________
//_____________________________________________________________________________
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;
}
-
-