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 "AliMUON1DArray.h"
21 #include "TObjArray.h"
24 /// \class AliMUON1DArray
25 /// This class is simply a wrapper to a TObjArray, offering in addition a
26 /// control over the replacement policy when you add
29 /// \author Laurent Aphecetche
32 ClassImp(AliMUON1DArray)
35 //_____________________________________________________________________________
36 AliMUON1DArray::AliMUON1DArray(Int_t theSize)
44 fArray = new TObjArray(theSize);
48 //_____________________________________________________________________________
49 AliMUON1DArray::AliMUON1DArray(const AliMUON1DArray& other)
58 //_____________________________________________________________________________
60 AliMUON1DArray::operator=(const AliMUON1DArray& other)
62 /// Assignment operator
68 //_____________________________________________________________________________
69 AliMUON1DArray::~AliMUON1DArray()
71 /// dtor, we're the owner of our internal array.
76 //_____________________________________________________________________________
78 AliMUON1DArray::CopyTo(AliMUON1DArray& dest) const
83 dest.fArray = new TObjArray;
84 dest.fArray->SetOwner(kTRUE);
85 for ( Int_t i = 0; i < fArray->GetLast(); ++i )
87 dest.fArray->AddAt(fArray->At(i)->Clone(),i);
91 //_____________________________________________________________________________
93 AliMUON1DArray::Get(Int_t i) const
95 /// Get the object located at index i, if it exists, and if i is correct.
97 if ( i >= 0 && i < fArray->GetSize() )
101 AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));
105 //_____________________________________________________________________________
107 AliMUON1DArray::Set(Int_t i, TObject* object, Bool_t replace)
109 /// Set the object located at i
110 /// If replace=kFALSE and there's already an object at location i,
111 /// this method fails and returns kFALSE, otherwise it returns kTRUE
113 if ( i >= 0 && i < fArray->GetSize() )
118 AliError(Form("Object %p is already there for i=%d",o,i));
125 fArray->AddAt(object,i);
128 AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));