Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TArray Class Referenceabstract

Abstract array base class.

Used by TArrayC, TArrayS, TArrayI, TArrayL, TArrayF and TArrayD. Data member is public for historical reasons.

PyROOT

When used from Python, the subclasses of TArray (TArrayC, TArrayS, TArrayI, TArrayL, TArrayF and TArrayD) benefit from the following extra features:

  • Their size can be obtained with len, which is equivalent to TArray::GetSize():
    import ROOT
    a = ROOT.TArrayD(2)
    print(len(a)) # prints '2'
  • Their elements can be read and written with the getitem and setitem operators, respectively:
    a[0] = 0.2
    a[1] = 1.7
    print(a[0]) # prints '0.2'
  • They are iterable:
    for elem in a:
    print(elem)

Definition at line 31 of file TArray.h.

Public Member Functions

 TArray ()
 
 TArray (const TArray &a)
 
 TArray (Int_t n)
 
virtual ~TArray ()
 
virtual Double_t GetAt (Int_t i) const =0
 
Int_t GetSize () const
 
TArrayoperator= (const TArray &rhs)
 
virtual void Set (Int_t n)=0
 
virtual void SetAt (Double_t v, Int_t i)=0
 

Static Public Member Functions

static TArrayReadArray (TBuffer &b, const TClass *clReq)
 Read TArray object from buffer.
 
static void WriteArray (TBuffer &b, const TArray *a)
 Write TArray object to buffer.
 

Public Attributes

Int_t fN
 

Protected Member Functions

Bool_t BoundsOk (const char *where, Int_t at) const
 
Bool_t OutOfBoundsError (const char *where, Int_t i) const
 Generate an out-of-bounds error. Always returns false.
 

Friends

TBufferoperator<< (TBuffer &b, const TArray *obj)
 Write TArray or derived object to buffer.
 

#include <TArray.h>

Inheritance diagram for TArray:
[legend]

Constructor & Destructor Documentation

◆ TArray() [1/3]

TArray::TArray ( )
inline

Definition at line 40 of file TArray.h.

◆ TArray() [2/3]

TArray::TArray ( Int_t  n)
inline

Definition at line 41 of file TArray.h.

◆ TArray() [3/3]

TArray::TArray ( const TArray a)
inline

Definition at line 42 of file TArray.h.

◆ ~TArray()

virtual TArray::~TArray ( )
inlinevirtual

Definition at line 45 of file TArray.h.

Member Function Documentation

◆ BoundsOk()

Bool_t TArray::BoundsOk ( const char *  where,
Int_t  at 
) const
inlineprotected

Definition at line 77 of file TArray.h.

◆ GetAt()

virtual Double_t TArray::GetAt ( Int_t  i) const
pure virtual

Implemented in TArrayC, TArrayD, TArrayF, TArrayI, TArrayL, TArrayL64, and TArrayS.

◆ GetSize()

Int_t TArray::GetSize ( ) const
inline

Definition at line 47 of file TArray.h.

◆ operator=()

TArray & TArray::operator= ( const TArray rhs)
inline

Definition at line 43 of file TArray.h.

◆ OutOfBoundsError()

Bool_t TArray::OutOfBoundsError ( const char *  where,
Int_t  i 
) const
protected

Generate an out-of-bounds error. Always returns false.

Definition at line 30 of file TArray.cxx.

◆ ReadArray()

TArray * TArray::ReadArray ( TBuffer b,
const TClass clReq 
)
static

Read TArray object from buffer.

Simplified version of TBuffer::ReadObject (does not keep track of multiple references to same array).

Definition at line 41 of file TArray.cxx.

◆ Set()

virtual void TArray::Set ( Int_t  n)
pure virtual

Implemented in TArrayC, TArrayD, TArrayF, TArrayI, TArrayL, TArrayL64, and TArrayS.

◆ SetAt()

virtual void TArray::SetAt ( Double_t  v,
Int_t  i 
)
pure virtual

Implemented in TArrayC, TArrayD, TArrayF, TArrayI, TArrayL, TArrayL64, and TArrayS.

◆ WriteArray()

void TArray::WriteArray ( TBuffer b,
const TArray a 
)
static

Write TArray object to buffer.

Simplified version of TBuffer::WriteObject (does not keep track of multiple references to the same array).

Definition at line 82 of file TArray.cxx.

Friends And Related Symbol Documentation

◆ operator<<

TBuffer & operator<< ( TBuffer b,
const TArray obj 
)
friend

Write TArray or derived object to buffer.

Definition at line 112 of file TArray.cxx.

Member Data Documentation

◆ fN

Int_t TArray::fN

Definition at line 38 of file TArray.h.

  • core/cont/inc/TArray.h
  • core/cont/src/TArray.cxx