Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TArrayI.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_TArrayI
13#define ROOT_TArrayI
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TArrayI //
19// //
20// Array of integers (32 bits per element). //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TArray.h"
25
26
27class TArrayI : public TArray {
28
29public:
30 Int_t *fArray; //[fN] Array of fN 32 bit integers
31
32 TArrayI();
34 TArrayI(Int_t n, const Int_t *array);
35 TArrayI(const TArrayI &array);
36 TArrayI &operator=(const TArrayI &rhs);
37 virtual ~TArrayI();
38
39 void Adopt(Int_t n, Int_t *array);
40 void AddAt(Int_t c, Int_t i);
41 Int_t At(Int_t i) const ;
42 void Copy(TArrayI &array) const {array.Set(fN,fArray);}
43 const Int_t *GetArray() const { return fArray; }
44 Int_t *GetArray() { return fArray; }
45 Double_t GetAt(Int_t i) const override { 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(Int_t));}
48 void Reset(Int_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
49 void Set(Int_t n) override;
50 void Set(Int_t n, const Int_t *array);
51 void SetAt(Double_t v, Int_t i) override { AddAt((Int_t)v, i); }
53 Int_t operator[](Int_t i) const;
54
55 ClassDefOverride(TArrayI,1) //Array of ints
56};
57
58
59#if defined R__TEMPLATE_OVERLOAD_BUG
60template <>
61#endif
62inline TBuffer &operator>>(TBuffer &buf, TArrayI *&obj)
63{
64 // Read TArrayI object from buffer.
65
67 return buf;
68}
69
70#if defined R__TEMPLATE_OVERLOAD_BUG
71template <>
72#endif
73inline TBuffer &operator<<(TBuffer &buf, const TArrayI *obj)
74{
75 // Write a TArrayI object into buffer
76 return buf << (const TArray*)obj;
77}
78
79inline Int_t TArrayI::At(Int_t i) const
80{
81 if (!BoundsOk("TArrayI::At", i)) return 0;
82 return fArray[i];
83}
84
86{
87 if (!BoundsOk("TArrayI::operator[]", i))
88 i = 0;
89 return fArray[i];
90}
91
93{
94 if (!BoundsOk("TArrayI::operator[]", i)) return 0;
95 return fArray[i];
96}
97
98#endif
#define c(i)
Definition RSha256.hxx:101
int Int_t
Definition RtypesCore.h:45
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
TBuffer & operator>>(TBuffer &buf, TArrayI *&obj)
Definition TArrayI.h:62
Array of integers (32 bits per element).
Definition TArrayI.h:27
Int_t * GetArray()
Definition TArrayI.h:44
Int_t * fArray
Definition TArrayI.h:30
Int_t & operator[](Int_t i)
Definition TArrayI.h:85
void Reset(Int_t val)
Definition TArrayI.h:48
static TClass * Class()
void Adopt(Int_t n, Int_t *array)
Adopt array arr into TArrayI, i.e.
Definition TArrayI.cxx:81
void Set(Int_t n) override
Set size of this array to n ints.
Definition TArrayI.cxx:105
Double_t GetAt(Int_t i) const override
Definition TArrayI.h:45
void Reset()
Definition TArrayI.h:47
void SetAt(Double_t v, Int_t i) override
Definition TArrayI.h:51
const Int_t * GetArray() const
Definition TArrayI.h:43
Stat_t GetSum() const
Definition TArrayI.h:46
Int_t At(Int_t i) const
Definition TArrayI.h:79
virtual ~TArrayI()
Delete TArrayI object.
Definition TArrayI.cxx:71
TArrayI & operator=(const TArrayI &rhs)
TArrayI assignment operator.
Definition TArrayI.cxx:61
void AddAt(Int_t c, Int_t i)
Add Int_t c at position i. Check for out of bounds.
Definition TArrayI.cxx:93
void Copy(TArrayI &array) const
Definition TArrayI.h:42
TArrayI()
Default TArrayI ctor.
Definition TArrayI.cxx:26
Abstract array base class.
Definition TArray.h:31
Int_t fN
Definition TArray.h:38
Bool_t BoundsOk(const char *where, Int_t at) const
Definition TArray.h:77
static TArray * ReadArray(TBuffer &b, const TClass *clReq)
Read TArray object from buffer.
Definition TArray.cxx:41
Buffer base class used for serializing objects.
Definition TBuffer.h:43
const Int_t n
Definition legend1.C:16
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345