Logo ROOT   6.12/07
Reference Guide
TArrayL.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Rene Brun 06/03/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TArrayL
13 #define ROOT_TArrayL
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TArrayL //
19 // //
20 // Array of longs (32 or 64 bits per element). //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TArray.h"
25 
26 
27 class TArrayL : public TArray {
28 
29 public:
30  Long_t *fArray; //[fN] Array of fN longs
31 
32  TArrayL();
33  TArrayL(Int_t n);
34  TArrayL(Int_t n, const Long_t *array);
35  TArrayL(const TArrayL &array);
36  TArrayL &operator=(const TArrayL &rhs);
37  virtual ~TArrayL();
38 
39  void Adopt(Int_t n, Long_t *array);
40  void AddAt(Long_t c, Int_t i);
41  Long_t At(Int_t i) const;
42  void Copy(TArrayL &array) const {array.Set(fN,fArray);}
43  const Long_t *GetArray() const { return fArray; }
44  Long_t *GetArray() { return fArray; }
45  Double_t GetAt(Int_t i) const { return At(i); }
46  Stat_t GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
47  void Reset() {memset(fArray, 0, fN*sizeof(Long_t));}
48  void Reset(Long_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
49  void Set(Int_t n);
50  void Set(Int_t n, const Long_t *array);
51  void SetAt(Double_t v, Int_t i) { AddAt((Long_t)v, i); }
53  Long_t operator[](Int_t i) const;
54 
55  ClassDef(TArrayL,1) //Array of longs
56 };
57 
58 
59 
60 #if defined R__TEMPLATE_OVERLOAD_BUG
61 template <>
62 #endif
63 inline TBuffer &operator>>(TBuffer &buf, TArrayL *&obj)
64 {
65  // Read TArrayL object from buffer.
66 
67  obj = (TArrayL *) TArray::ReadArray(buf, TArrayL::Class());
68  return buf;
69 }
70 
71 #if defined R__TEMPLATE_OVERLOAD_BUG
72 template <>
73 #endif
74 inline TBuffer &operator<<(TBuffer &buf, const TArrayL *obj)
75 {
76  // Write a TArrayL object into buffer
77  return buf << (const TArray*)obj;
78 }
79 
80 inline Long_t TArrayL::At(Int_t i) const
81 {
82  if (!BoundsOk("TArrayL::At", i)) return 0;
83  return fArray[i];
84 }
85 
87 {
88  if (!BoundsOk("TArrayL::operator[]", i))
89  i = 0;
90  return fArray[i];
91 }
92 
94 {
95  if (!BoundsOk("TArrayL::operator[]", i)) return 0;
96  return fArray[i];
97 }
98 
99 #endif
Abstract array base class.
Definition: TArray.h:31
void Set(Int_t n)
Set size of this array to n longs.
Definition: TArrayL.cxx:105
static long int sum(long int i)
Definition: Factory.cxx:2173
const Long_t * GetArray() const
Definition: TArrayL.h:43
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual ~TArrayL()
Delete TArrayL object.
Definition: TArrayL.cxx:71
int Int_t
Definition: RtypesCore.h:41
void Adopt(Int_t n, Long_t *array)
Adopt array arr into TArrayL, i.e.
Definition: TArrayL.cxx:81
void SetAt(Double_t v, Int_t i)
Definition: TArrayL.h:51
Long_t * GetArray()
Definition: TArrayL.h:44
#define ClassDef(name, id)
Definition: Rtypes.h:320
void Class()
Definition: Class.C:29
Bool_t BoundsOk(const char *where, Int_t at) const
Definition: TArray.h:77
void Copy(TArrayL &array) const
Definition: TArrayL.h:42
TArrayL & operator=(const TArrayL &rhs)
TArrayL assignment operator.
Definition: TArrayL.cxx:61
TArrayL()
Default TArrayL ctor.
Definition: TArrayL.cxx:26
Int_t fN
Definition: TArray.h:38
SVector< double, 2 > v
Definition: Dict.h:5
static TArray * ReadArray(TBuffer &b, const TClass *clReq)
Read TArray object from buffer.
Definition: TArray.cxx:41
Array of longs (32 or 64 bits per element).
Definition: TArrayL.h:27
void AddAt(Long_t c, Int_t i)
Add long c at position i. Check for out of bounds.
Definition: TArrayL.cxx:93
Long_t At(Int_t i) const
Definition: TArrayL.h:80
Long_t * fArray
Definition: TArrayL.h:30
long Long_t
Definition: RtypesCore.h:50
friend TBuffer & operator<<(TBuffer &b, const TArray *obj)
Write TArray or derived object to buffer.
Definition: TArray.cxx:112
double Double_t
Definition: RtypesCore.h:55
Long_t & operator[](Int_t i)
Definition: TArrayL.h:86
void Reset()
Definition: TArrayL.h:47
double Stat_t
Definition: RtypesCore.h:73
TBuffer & operator>>(TBuffer &buf, TArrayL *&obj)
Definition: TArrayL.h:63
Double_t GetAt(Int_t i) const
Definition: TArrayL.h:45
void Reset(Long_t val)
Definition: TArrayL.h:48
const Int_t n
Definition: legend1.C:16
Stat_t GetSum() const
Definition: TArrayL.h:46