TArrayI.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Id: TArrayI.h 30676 2009-10-12 13:54:12Z brun $
00002 // Author: Rene Brun   06/03/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TArrayI
00013 #define ROOT_TArrayI
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TArrayI                                                              //
00019 //                                                                      //
00020 // Array of integers (32 bits per element).                             //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TArray
00025 #include "TArray.h"
00026 #endif
00027 
00028 
00029 class TArrayI : public TArray {
00030 
00031 public:
00032    Int_t    *fArray;       //[fN] Array of fN 32 bit integers
00033 
00034    TArrayI();
00035    TArrayI(Int_t n);
00036    TArrayI(Int_t n, const Int_t *array);
00037    TArrayI(const TArrayI &array);
00038    TArrayI    &operator=(const TArrayI &rhs);
00039    virtual    ~TArrayI();
00040 
00041    void         Adopt(Int_t n, Int_t *array);
00042    void         AddAt(Int_t c, Int_t i);
00043    Int_t        At(Int_t i) const ;
00044    void         Copy(TArrayI &array) const {array.Set(fN,fArray);}
00045    const Int_t *GetArray() const { return fArray; }
00046    Int_t       *GetArray() { return fArray; }
00047    Double_t     GetAt(Int_t i) const { return At(i); }
00048    Stat_t       GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
00049    void         Reset()           {memset(fArray, 0, fN*sizeof(Int_t));}
00050    void         Reset(Int_t val)  {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
00051    void         Set(Int_t n);
00052    void         Set(Int_t n, const Int_t *array);
00053    void         SetAt(Double_t v, Int_t i) { AddAt((Int_t)v, i); }
00054    Int_t       &operator[](Int_t i);
00055    Int_t        operator[](Int_t i) const;
00056 
00057    ClassDef(TArrayI,1)  //Array of ints
00058 };
00059 
00060 
00061 #if defined R__TEMPLATE_OVERLOAD_BUG
00062 template <>
00063 #endif
00064 inline TBuffer &operator>>(TBuffer &buf, TArrayI *&obj)
00065 {
00066    // Read TArrayI object from buffer.
00067 
00068    obj = (TArrayI *) TArray::ReadArray(buf, TArrayI::Class());
00069    return buf;
00070 }
00071 
00072 #if defined R__TEMPLATE_OVERLOAD_BUG
00073 template <>
00074 #endif
00075 inline TBuffer &operator<<(TBuffer &buf, const TArrayI *obj)
00076 {
00077    // Write a TArrayI object into buffer
00078    return buf << (TArray*)obj;
00079 }
00080 
00081 inline Int_t TArrayI::At(Int_t i) const
00082 {
00083    if (!BoundsOk("TArrayI::At", i)) return 0;
00084    return fArray[i];
00085 }
00086 
00087 inline Int_t &TArrayI::operator[](Int_t i)
00088 {
00089    if (!BoundsOk("TArrayI::operator[]", i))
00090       i = 0;
00091    return fArray[i];
00092 }
00093 
00094 inline Int_t TArrayI::operator[](Int_t i) const
00095 {
00096    if (!BoundsOk("TArrayI::operator[]", i)) return 0;
00097    return fArray[i];
00098 }
00099 
00100 #endif

Generated on Tue Jul 5 14:11:25 2011 for ROOT_528-00b_version by  doxygen 1.5.1