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_TArrayL
0013 #define ROOT_TArrayL
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TArrayL                                                              //
0019 //                                                                      //
0020 // Array of longs (32 or 64 bits per element).                          //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TArray.h"
0025 
0026 
0027 class TArrayL : public TArray {
0028 
0029 public:
0030    Long_t *fArray;       //[fN] Array of fN longs
0031 
0032    TArrayL();
0033    TArrayL(Int_t n);
0034    TArrayL(Int_t n, const Long_t *array);
0035    TArrayL(const TArrayL &array);
0036    TArrayL    &operator=(const TArrayL &rhs);
0037    virtual    ~TArrayL();
0038 
0039    void          Adopt(Int_t n, Long_t *array);
0040    void          AddAt(Long_t c, Int_t i);
0041    Long_t        At(Int_t i) const;
0042    void          Copy(TArrayL &array) const {array.Set(fN,fArray);}
0043    const Long_t *GetArray() const { return fArray; }
0044    Long_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(Long_t));}
0048    void          Reset(Long_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 Long_t *array);
0051    void          SetAt(Double_t v, Int_t i) override { AddAt((Long_t)v, i); }
0052    Long_t       &operator[](Int_t i);
0053    Long_t        operator[](Int_t i) const;
0054 
0055    ClassDefOverride(TArrayL,1)  //Array of longs
0056 };
0057 
0058 
0059 
0060 #if defined R__TEMPLATE_OVERLOAD_BUG
0061 template <>
0062 #endif
0063 inline TBuffer &operator>>(TBuffer &buf, TArrayL *&obj)
0064 {
0065    // Read TArrayL object from buffer.
0066 
0067    obj = (TArrayL *) TArray::ReadArray(buf, TArrayL::Class());
0068    return buf;
0069 }
0070 
0071 #if defined R__TEMPLATE_OVERLOAD_BUG
0072 template <>
0073 #endif
0074 inline TBuffer &operator<<(TBuffer &buf, const TArrayL *obj)
0075 {
0076    // Write a TArrayL object into buffer
0077    return buf << (const TArray*)obj;
0078 }
0079 
0080 inline Long_t TArrayL::At(Int_t i) const
0081 {
0082    if (!BoundsOk("TArrayL::At", i)) return 0;
0083    return fArray[i];
0084 }
0085 
0086 inline Long_t &TArrayL::operator[](Int_t i)
0087 {
0088    if (!BoundsOk("TArrayL::operator[]", i))
0089       i = 0;
0090    return fArray[i];
0091 }
0092 
0093 inline Long_t TArrayL::operator[](Int_t i) const
0094 {
0095    if (!BoundsOk("TArrayL::operator[]", i)) return 0;
0096    return fArray[i];
0097 }
0098 
0099 #endif