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));
}
}
--------------------------------------------------------------------------------