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

TArrayS.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Name:  $:$Id: TArrayS.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_TArrayS
00013 #define ROOT_TArrayS
00014 
00015 
00017 //                                                                      //
00018 // TArrayS                                                              //
00019 //                                                                      //
00020 // Array of shorts (16 bits per element).                               //
00021 //                                                                      //
00023 
00024 #ifndef ROOT_TArray
00025 #include "TArray.h"
00026 #endif
00027 
00028 
00029 class TArrayS : public TArray {
00030 
00031 public:
00032    Short_t    *fArray;       //[fN] Array of fN shorts
00033 
00034    TArrayS();
00035    TArrayS(Int_t n);
00036    TArrayS(Int_t n, const Short_t *array);
00037    TArrayS(const TArrayS &array);
00038    TArrayS    &operator=(const TArrayS &rhs);
00039    virtual    ~TArrayS();
00040 
00041    void           Adopt(Int_t n, Short_t *array);
00042    void           AddAt(Short_t c, Int_t idx);
00043    Short_t        At(Int_t i) const ;
00044    void           Copy(TArrayS &array) const {array.Set(fN); for (Int_t i=0;i<fN;i++) array.fArray[i] = fArray[i];}
00045    const Short_t *GetArray() const { return fArray; }
00046    Short_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(Short_t));}
00049    void           Reset(Short_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 Short_t *array);
00052    Short_t       &operator[](Int_t i);
00053    Short_t        operator[](Int_t i) const;
00054 
00055    ClassDef(TArrayS,1)  //Array of shorts
00056 };
00057 
00058 #if defined R__TEMPLATE_OVERLOAD_BUG
00059 template <>
00060 #endif
00061 inline TBuffer &operator>>(TBuffer &buf, TArrayS *&obj)
00062 {
00063    // Read TArrayS object from buffer.
00064 
00065    obj = (TArrayS *) TArray::ReadArray(buf, TArrayS::Class());
00066    return buf;
00067 }
00068 
00069 #if defined R__TEMPLATE_OVERLOAD_BUG
00070 template <>
00071 #endif
00072 inline TBuffer &operator<<(TBuffer &buf, const TArrayS *obj)
00073 {
00074    // Write a TArrayS object into buffer
00075    return buf << (TArray*)obj;
00076 }
00077 
00078 inline Short_t TArrayS::At(Int_t i) const
00079 {
00080    if (!BoundsOk("TArrayS::At", i)) return 0;
00081    return fArray[i];
00082 }
00083 
00084 inline Short_t &TArrayS::operator[](Int_t i)
00085 {
00086    if (!BoundsOk("TArrayS::operator[]", i))
00087       i = 0;
00088    return fArray[i];
00089 }
00090 
00091 inline Short_t TArrayS::operator[](Int_t i) const
00092 {
00093    if (!BoundsOk("TArrayS::operator[]", i)) return 0;
00094    return fArray[i];
00095 }
00096 
00097 #endif

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