proposal: modification of TArray*::Set method

From: Pasha Murat (murat@cdfsga.fnal.gov)
Date: Wed Oct 15 1997 - 18:41:50 MEST


	Hello, 

I'd like to propose a modification of TArray*::Set method to add a
very useful feature of initializing TArray with an existing data 
(see example for TArrayI below).

				Any comments?    Pasha.

P.S. This shouldn't require any changes in the ROOT sources different from 
     TArray files

--------------------------------------------------------------------------------
class TArrayI {
...                                     // if `array' is not NULL, use the data
                                        // stored there for initialization

  void TArrayI::Set(Int_t n, Int_t* array = 0);
....
};

void TArrayI::Set(Int_t n, Int_t* array) {

   // Set array size of TArrayI object to n chars. If n<0 leave array unchanged.

   if (n < 0) return;
   if (fArray && fN != n) {
      delete [] fArray;
      fArray = 0;
   }
   fN = n;
   if (fN == 0) return;
   if (!fArray) fArray = new Int_t[fN];

   if (array) {
     memcpy(fArray,array,fN*sizeof(Int_t));
   }	 
   else {
     memset(fArray,0,fN*sizeof(Int_t));
   }
}
--------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET