Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

TArrayI.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Name:  $:$Id: TArrayI.h,v 1.14 2002/10/30 20:39:50 brun Exp $
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 
00017 //                                                                      //
00018 // TArrayI                                                              //
00019 //                                                                      //
00020 // Array of integers (32 bits per element).                             //
00021 //                                                                      //
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 i, Int_t idx);
00043    Int_t        At(Int_t i) const ;
00044    void         Copy(TArrayI &array) const {array.Set(fN); for (Int_t i=0;i<fN;i++) array.fArray[i] = fArray[i];}
00045    const Int_t *GetArray() const { return fArray; }
00046    Int_t       *GetArray() { return fArray; }
00047    Stat_t       GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
00048    void         Reset()           {memset(fArray, 0, fN*sizeof(Int_t));}
00049    void         Reset(Int_t val)  {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
00050    void         Set(Int_t n);
00051    void         Set(Int_t n, const Int_t *array);
00052    Int_t       &operator[](Int_t i);
00053    Int_t        operator[](Int_t i) const;
00054 
00055    ClassDef(TArrayI,1)  //Array of ints
00056 };
00057 
00058 
00059 #if defined R__TEMPLATE_OVERLOAD_BUG
00060 template <>
00061 #endif
00062 inline TBuffer &operator>>(TBuffer &buf, TArrayI *&obj)
00063 {
00064    // Read TArrayI object from buffer.
00065 
00066    obj = (TArrayI *) TArray::ReadArray(buf, TArrayI::Class());
00067    return buf;
00068 }
00069 
00070 #if defined R__TEMPLATE_OVERLOAD_BUG
00071 template <>
00072 #endif
00073 inline TBuffer &operator<<(TBuffer &buf, const TArrayI *obj)
00074 {
00075    // Write a TArrayI object into buffer
00076    return buf << (TArray*)obj;
00077 }
00078 
00079 inline Int_t TArrayI::At(Int_t i) const
00080 {
00081    if (!BoundsOk("TArrayI::At", i)) return 0;
00082    return fArray[i];
00083 }
00084 
00085 inline Int_t &TArrayI::operator[](Int_t i)
00086 {
00087    if (!BoundsOk("TArrayI::operator[]", i))
00088       i = 0;
00089    return fArray[i];
00090 }
00091 
00092 inline Int_t TArrayI::operator[](Int_t i) const
00093 {
00094    if (!BoundsOk("TArrayI::operator[]", i)) return 0;
00095    return fArray[i];
00096 }
00097 
00098 #endif

Generated on Thu Dec 18 14:52:16 2003 for ROOT by doxygen1.2.16