ROOT  6.06/09
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 #ifndef ROOT_TArray
25 #include "TArray.h"
26 #endif
27 
28 
29 class TArrayL : public TArray {
30 
31 public:
32  Long_t *fArray; //[fN] Array of fN longs
33 
34  TArrayL();
35  TArrayL(Int_t n);
36  TArrayL(Int_t n, const Long_t *array);
37  TArrayL(const TArrayL &array);
38  TArrayL &operator=(const TArrayL &rhs);
39  virtual ~TArrayL();
40 
41  void Adopt(Int_t n, Long_t *array);
42  void AddAt(Long_t c, Int_t i);
43  Long_t At(Int_t i) const;
44  void Copy(TArrayL &array) const {array.Set(fN,fArray);}
45  const Long_t *GetArray() const { return fArray; }
46  Long_t *GetArray() { return fArray; }
47  Double_t GetAt(Int_t i) const { return At(i); }
48  Stat_t GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
49  void Reset() {memset(fArray, 0, fN*sizeof(Long_t));}
50  void Reset(Long_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
51  void Set(Int_t n);
52  void Set(Int_t n, const Long_t *array);
53  void SetAt(Double_t v, Int_t i) { AddAt((Long_t)v, i); }
55  Long_t operator[](Int_t i) const;
56 
57  ClassDef(TArrayL,1) //Array of longs
58 };
59 
60 
61 
62 #if defined R__TEMPLATE_OVERLOAD_BUG
63 template <>
64 #endif
66 {
67  // Read TArrayL object from buffer.
68 
69  obj = (TArrayL *) TArray::ReadArray(buf, TArrayL::Class());
70  return buf;
71 }
72 
73 #if defined R__TEMPLATE_OVERLOAD_BUG
74 template <>
75 #endif
76 inline TBuffer &operator<<(TBuffer &buf, const TArrayL *obj)
77 {
78  // Write a TArrayL object into buffer
79  return buf << (const TArray*)obj;
80 }
81 
82 inline Long_t TArrayL::At(Int_t i) const
83 {
84  if (!BoundsOk("TArrayL::At", i)) return 0;
85  return fArray[i];
86 }
87 
89 {
90  if (!BoundsOk("TArrayL::operator[]", i))
91  i = 0;
92  return fArray[i];
93 }
94 
96 {
97  if (!BoundsOk("TArrayL::operator[]", i)) return 0;
98  return fArray[i];
99 }
100 
101 #endif
Abstract array base class.
Definition: TArray.h:33
void Set(Int_t n)
Set size of this array to n longs.
Definition: TArrayL.cxx:104
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual ~TArrayL()
Delete TArrayL object.
Definition: TArrayL.cxx:70
Stat_t GetSum() const
Definition: TArrayL.h:48
int Int_t
Definition: RtypesCore.h:41
TBuffer & operator<<(TBuffer &buf, const TArrayL *obj)
Definition: TArrayL.h:76
void Adopt(Int_t n, Long_t *array)
Adopt array arr into TArrayL, i.e.
Definition: TArrayL.cxx:80
void SetAt(Double_t v, Int_t i)
Definition: TArrayL.h:53
Long_t * GetArray()
Definition: TArrayL.h:46
#define ClassDef(name, id)
Definition: Rtypes.h:254
void Class()
Definition: Class.C:29
TArrayL & operator=(const TArrayL &rhs)
TArrayL assignment operator.
Definition: TArrayL.cxx:60
Long_t At(Int_t i) const
Definition: TArrayL.h:82
Int_t fN
Definition: TArray.h:40
void Copy(TArrayL &array) const
Definition: TArrayL.h:44
Bool_t BoundsOk(const char *where, Int_t at) const
Definition: TArray.h:79
SVector< double, 2 > v
Definition: Dict.h:5
static TArray * ReadArray(TBuffer &b, const TClass *clReq)
Read TArray object from buffer.
Definition: TArray.cxx:40
Array of longs (32 or 64 bits per element).
Definition: TArrayL.h:29
void AddAt(Long_t c, Int_t i)
Add long c at position i. Check for out of bounds.
Definition: TArrayL.cxx:92
Long_t * fArray
Definition: TArrayL.h:32
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
Long_t & operator[](Int_t i)
Definition: TArrayL.h:88
void Reset()
Definition: TArrayL.h:49
Double_t GetAt(Int_t i) const
Definition: TArrayL.h:47
double Stat_t
Definition: RtypesCore.h:73
TBuffer & operator>>(TBuffer &buf, TArrayL *&obj)
Definition: TArrayL.h:65
const Long_t * GetArray() const
Definition: TArrayL.h:45
void Reset(Long_t val)
Definition: TArrayL.h:50
TObject * obj
const Int_t n
Definition: legend1.C:16