]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliObjMatrix.cxx
wrap some insanely long lines into mulitple lines.
[u/mrichter/AliRoot.git] / RALICE / AliObjMatrix.cxx
index 1a2ced9212dbd34e25742536623e36e399728f32..8a5332dcdaf68df39c159da7c40eb5ed937873ec 100644 (file)
@@ -159,7 +159,7 @@ void AliObjMatrix::SetOwner(Int_t own)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetOwner()
+Int_t AliObjMatrix::GetOwner() const
 {
 // Provide the owner flag for the stored objects.
  return fOwn;
@@ -189,7 +189,7 @@ void AliObjMatrix::SetSwapMode(Int_t swap)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetSwapMode()
+Int_t AliObjMatrix::GetSwapMode() const
 {
 // Provide the swap mode flag for this matrix.
  return fSwap;
@@ -289,9 +289,9 @@ void AliObjMatrix::RemoveObject(Int_t row,Int_t col)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliObjMatrix::RemoveObject(TObject* obj,Int_t row,Int_t col)
+void AliObjMatrix::RemoveObjects(TObject* obj,Int_t row,Int_t col)
 {
-// Remove an object from the matrix according to user specified selections.
+// Remove object(s) from the matrix according to user specified selections.
 // In case the object was owned by the matrix, it will be deleted.
 //
 // An object is only removed from the matrix if the stored reference matches
@@ -308,19 +308,19 @@ void AliObjMatrix::RemoveObject(TObject* obj,Int_t row,Int_t col)
 // that matrix column will be deleted.
 // In case col=0 (default) no checking on the column index is performed.
 //
-// So, invokation of RemoveObject(obj) will remove all references to the
-// object "obj" from the total matrix, whereas RemoveObject(obj,0,col)
+// So, invokation of RemoveObjects(obj) will remove all references to the
+// object "obj" from the total matrix, whereas RemoveObjects(obj,0,col)
 // will remove all references to the object "obj" only from column "col".
 //
 // Notes :
 // -------
 // The first location in the matrix is indicated as (1,1).
 //
-// Invokation of RemoveObject(0,row,col) is equivalent to invoking the
+// Invokation of RemoveObjects(0,row,col) is equivalent to invoking the
 // memberfunction RemoveObject(row,col).
 // Invoking the latter directly is slightly faster.
 //
-// Invokation of RemoveObject(0) is equivalent to invoking Reset().
+// Invokation of RemoveObjects(0) is equivalent to invoking Reset().
 // Invoking the latter directly is slightly faster.
 //
  TArrayI rows;
@@ -369,7 +369,7 @@ void AliObjMatrix::RemoveObject(TObject* obj,Int_t row,Int_t col)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-TObject* AliObjMatrix::GetObject(Int_t row,Int_t col)
+TObject* AliObjMatrix::GetObject(Int_t row,Int_t col) const
 {
 // Provide a pointer to the object stored at the matrix location (row,col).
 // In case no object was stored at the indicated location or the location
@@ -396,15 +396,15 @@ TObject* AliObjMatrix::GetObject(Int_t row,Int_t col)
  return obj;
 }
 ///////////////////////////////////////////////////////////////////////////
-TObject* AliObjMatrix::GetObject(Int_t j)
+TObject* AliObjMatrix::GetObject(Int_t j) const
 {
 // Provide a pointer to the j-th stored object.
 // In case the index j is invalid, a value 0 will be returned.
 // The first stored object is indicated as j=1.
 //
 // Note : Do NOT delete the object.
-//        To remove an object, the memberfunction RemoveObject()
-//        should be used.
+//        To remove an object, the memberfunction RemoveObject() or
+//        RemoveObjects() should be used.
 
  TObject* obj=0;
  Int_t nobj=0;
@@ -423,24 +423,24 @@ TObjArray* AliObjMatrix::GetObjects()
 // Note : Do NOT make any changes to the reference array apart from
 //        changing the order of the pointers of the various objects.
 //        For addition or removal of objects, the memberfunctions
-//        EnterObject() and RemoveObject() should be used.
+//        EnterObject(), RemoveObject() or RemoveObjects() should be used.
 
  return fObjects;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetMaxRow()
+Int_t AliObjMatrix::GetMaxRow() const
 {
 // Provide the maximum row number index.
  return fMaxrow;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetMaxColumn()
+Int_t AliObjMatrix::GetMaxColumn() const
 {
 // Provide the maximum column number index.
  return fMaxcol;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetNobjects()
+Int_t AliObjMatrix::GetNobjects() const
 {
 // Provide the number of stored objects.
  Int_t nobj=0;
@@ -449,7 +449,7 @@ Int_t AliObjMatrix::GetNobjects()
  return nobj;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetNrefs(TObject* obj)
+Int_t AliObjMatrix::GetNrefs(TObject* obj) const
 {
 // Provide the number of stored references to the specified object.
 // If obj=0 the total number of stored references for all objects is returned.
@@ -466,7 +466,7 @@ Int_t AliObjMatrix::GetNrefs(TObject* obj)
  return nrefs;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols)
+Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols) const
 {
 // Provide the (row,col) indices of all the storage locations of the
 // specified object.
@@ -528,7 +528,7 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols)
  return nrefs;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
+Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols) const
 {
 // Provide the column indices of all the storage locations of the
 // specified object in the specified row of the matrix.
@@ -537,7 +537,13 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
 // were encountered for the specified object in the specified matrix row.
 //
 // If obj=0 no object selection is performed and all column indices
-// of the stored references for all objects are returned.
+// of the stored references for all objects in this specified matrix row
+// are returned.
+//
+// If row=0 all rows will be scanned and all column indices matching the
+// object selection are returned.
+// Note that in this case multiple appearances of the same column index
+// will only be recorded once in the returned TArrayI array.
 //
 // Notes :
 // -------
@@ -552,15 +558,45 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
 // indices of that TObjArray are obtained and NOT the indices of the
 // actual objects contained in that TObjArray structure.
 //
- if (row<1 || row>GetMaxRow()) return 0;
+ cols.Reset();
+
+ if (row<0 || row>GetMaxRow()) return 0;
 
  Int_t nrefs=GetNrefs(obj);
- cols.Reset();
  cols.Set(nrefs);
  if (!nrefs) return 0;
 
  Int_t irow,icol;
  Int_t jref=0;
+
+ // No specific row selection
+ if (!row)
+ {
+  TArrayI ar;
+  TArrayI ac;
+  Int_t n=GetIndices(obj,ar,ac);
+  Int_t found=0;
+  for (Int_t idx=0; idx<n; idx++)
+  {
+   icol=ac.At(idx);
+   found=0;
+   for (Int_t k=0; k<jref; k++)
+   {
+    if (icol==cols.At(k)) found=1;
+   }
+   if (!found)
+   {
+    cols.AddAt(icol,jref);
+    jref++;
+   }
+  }
+  // Set the array size to the actual number of different column indices
+  cols.Set(jref);
+
+  return jref;
+ }
+
+ // Specific row selection
  for (Int_t i=0; i<fRows->GetSize(); i++)
  {
   TObjArray* columns=(TObjArray*)fRows->At(i);
@@ -593,7 +629,7 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
  return jref;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col)
+Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col) const
 {
 // Provide the row indices of all the storage locations of the
 // specified object in the specified column of the matrix.
@@ -602,7 +638,13 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col)
 // were encountered for the specified object in the specified matrix column.
 //
 // If obj=0 no object selection is performed and all row indices
-// of the stored references for all objects are returned.
+// of the stored references for all objects in this specified matrix column
+// are returned.
+//
+// If col=0 all columns will be scanned and all row indices matching the
+// object selection are returned.
+// Note that in this case multiple appearances of the same row index
+// will only be recorded once in the returned TArrayI array.
 //
 // Notes :
 // -------
@@ -617,15 +659,45 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col)
 // indices of that TObjArray are obtained and NOT the indices of the
 // actual objects contained in that TObjArray structure.
 //
- if (col<1 || col>GetMaxColumn()) return 0;
+ rows.Reset();
+
+ if (col<0 || col>GetMaxColumn()) return 0;
 
  Int_t nrefs=GetNrefs(obj);
- rows.Reset();
  rows.Set(nrefs);
  if (!nrefs) return 0;
 
  Int_t irow,icol;
  Int_t jref=0;
+
+ // No specific column selection
+ if (!col)
+ {
+  TArrayI ar;
+  TArrayI ac;
+  Int_t n=GetIndices(obj,ar,ac);
+  Int_t found=0;
+  for (Int_t idx=0; idx<n; idx++)
+  {
+   irow=ar.At(idx);
+   found=0;
+   for (Int_t k=0; k<jref; k++)
+   {
+    if (irow==rows.At(k)) found=1;
+   }
+   if (!found)
+   {
+    rows.AddAt(irow,jref);
+    jref++;
+   }
+  }
+  // Set the array size to the actual number of different row indices
+  rows.Set(jref);
+
+  return jref;
+ }
+
+ // Specific column selection
  for (Int_t i=0; i<fRows->GetSize(); i++)
  {
   TObjArray* columns=(TObjArray*)fRows->At(i);