Belle II Software  release-08-01-10
ObjArrayIterator< ArrayType, ValueType > Class Template Reference

Optimizes class to iterate over TObjArray and classes inheriting from it. More...

#include <ArrayIterator.h>

Inheritance diagram for ObjArrayIterator< ArrayType, ValueType >:
Collaboration diagram for ObjArrayIterator< ArrayType, ValueType >:

Public Member Functions

 ObjArrayIterator ()=default
 default constructor
 
 ObjArrayIterator (ArrayType &array, size_t index)
 real constructor More...
 
 ObjArrayIterator (ArrayType const *array, bool end=false)
 Convenience constructor in case of a TClonesArray pointer. More...
 
 ObjArrayIterator (ArrayType const *const *array, bool end=false)
 Convenience constructor because we usually have a TClonesArray** member so this takes cares of the checks. More...
 
ObjArrayIterator< ArrayType, ValueType > & operator++ ()
 prefix increment
 
ObjArrayIterator< ArrayType, ValueType > operator++ (int)
 postfix increment
 
bool operator== (const ObjArrayIterator< ArrayType, ValueType > &rhs) const
 check equality.
 
bool operator!= (const ObjArrayIterator< ArrayType, ValueType > &rhs) const
 check inequality.
 
ValueType & operator* () const
 dereference.
 
ValueType * operator-> () const
 dereference.
 

Private Attributes

TObject ** m_array {nullptr}
 pointer to the fCont member of the TObjArray
 

Detailed Description

template<class ArrayType, class ValueType>
class Belle2::ObjArrayIterator< ArrayType, ValueType >

Optimizes class to iterate over TObjArray and classes inheriting from it.

iterators are invalidated if the size of the TObjArray is changed.

Definition at line 23 of file ArrayIterator.h.

Constructor & Destructor Documentation

◆ ObjArrayIterator() [1/3]

ObjArrayIterator ( ArrayType &  array,
size_t  index 
)
inline

real constructor

Parameters
arrayreference to the TObjArray instance we want to iterate over
indexinteger of the index we want to point to right away

Definition at line 31 of file ArrayIterator.h.

31 : m_array{array.GetObjectRef() + index} {}
TObject ** m_array
pointer to the fCont member of the TObjArray
Definition: ArrayIterator.h:70

◆ ObjArrayIterator() [2/3]

ObjArrayIterator ( ArrayType const *  array,
bool  end = false 
)
inlineexplicit

Convenience constructor in case of a TClonesArray pointer.

The "const *" is needed so that a const TClonesArray* can be passed in for const ObjArrayIterators

Parameters
arraypointer to where the array is located. If any of the two is NULL a default iterator is created
endif true point to after the array, otherwise point to the beginning

Definition at line 40 of file ArrayIterator.h.

◆ ObjArrayIterator() [3/3]

ObjArrayIterator ( ArrayType const *const *  array,
bool  end = false 
)
inlineexplicit

Convenience constructor because we usually have a TClonesArray** member so this takes cares of the checks.

The "const * const *" is needed so that a const TClonesArray** can be passed in for const ObjArrayIterators

Parameters
arraypointer to the pointer where the array is located. If any of the two is NULL a default iterator is created
endif true point to after the array, otherwise point to the beginning

Definition at line 54 of file ArrayIterator.h.


The documentation for this class was generated from the following file: