Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:29

0001 // @(#)root/cont:$Id$
0002 // Author: Rene Brun   06/03/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TArrayI
0013 #define ROOT_TArrayI
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TArrayI                                                              //
0019 //                                                                      //
0020 // Array of integers (32 bits per element).                             //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TArray.h"
0025 
0026 
0027 class TArrayI : public TArray {
0028 
0029 public:
0030    Int_t    *fArray;       //[fN] Array of fN 32 bit integers
0031 
0032    TArrayI();
0033    TArrayI(Int_t n);
0034    TArrayI(Int_t n, const Int_t *array);
0035    TArrayI(const TArrayI &array);
0036    TArrayI    &operator=(const TArrayI &rhs);
0037    virtual    ~TArrayI();
0038 
0039    void         Adopt(Int_t n, Int_t *array);
0040    void         AddAt(Int_t c, Int_t i);
0041    Int_t        At(Int_t i) const ;
0042    void         Copy(TArrayI &array) const {array.Set(fN,fArray);}
0043    const Int_t *GetArray() const { return fArray; }
0044    Int_t       *GetArray() { return fArray; }
0045    Double_t     GetAt(Int_t i) const override { return At(i); }
0046    Stat_t       GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
0047    void         Reset()           {memset(fArray, 0, fN*sizeof(Int_t));}
0048    void         Reset(Int_t val)  {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
0049    void         Set(Int_t n) override;
0050    void         Set(Int_t n, const Int_t *array);
0051    void         SetAt(Double_t v, Int_t i) override { AddAt((Int_t)v, i); }
0052    Int_t       &operator[](Int_t i);
0053    Int_t        operator[](Int_t i) const;
0054 
0055    ClassDefOverride(TArrayI,1)  //Array of ints
0056 };
0057 
0058 
0059 #if defined R__TEMPLATE_OVERLOAD_BUG
0060 template <>
0061 #endif
0062 inline TBuffer &operator>>(TBuffer &buf, TArrayI *&obj)
0063 {
0064    // Read TArrayI object from buffer.
0065 
0066    obj = (TArrayI *) TArray::ReadArray(buf, TArrayI::Class());
0067    return buf;
0068 }
0069 
0070 #if defined R__TEMPLATE_OVERLOAD_BUG
0071 template <>
0072 #endif
0073 inline TBuffer &operator<<(TBuffer &buf, const TArrayI *obj)
0074 {
0075    // Write a TArrayI object into buffer
0076    return buf << (const TArray*)obj;
0077 }
0078 
0079 inline Int_t TArrayI::At(Int_t i) const
0080 {
0081    if (!BoundsOk("TArrayI::At", i)) return 0;
0082    return fArray[i];
0083 }
0084 
0085 inline Int_t &TArrayI::operator[](Int_t i)
0086 {
0087    if (!BoundsOk("TArrayI::operator[]", i))
0088       i = 0;
0089    return fArray[i];
0090 }
0091 
0092 inline Int_t TArrayI::operator[](Int_t i) const
0093 {
0094    if (!BoundsOk("TArrayI::operator[]", i)) return 0;
0095    return fArray[i];
0096 }
0097 
0098 #endif