AliPhysics  b43479f (b43479f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliClusterContainer::accept_iterator Class Reference

stl iterator over accepted clusters More...

#include <AliClusterContainer.h>

Inheritance diagram for AliClusterContainer::accept_iterator:

Public Member Functions

 accept_iterator (const AliClusterContainer *cont, int startpos, bool forward=true)
 
 accept_iterator (const accept_iterator &other)
 
virtual ~accept_iterator ()
 
accept_iteratoroperator= (const accept_iterator &other)
 
bool operator!= (const accept_iterator &other) const
 
accept_iteratoroperator++ ()
 
accept_iterator operator++ (int)
 
accept_iteratoroperator-- ()
 
accept_iterator operator-- (int)
 
AliVCluster * operator* () const
 

Private Member Functions

 accept_iterator ()
 

Private Attributes

const AliClusterContainerfkContainer
 Container iterated over. More...
 
TArrayI fAcceptIndices
 Indices of accepted clusters. More...
 
int fCurrentPos
 Current position inside the container. More...
 
bool fForward
 Direction, expressed in forward direction. More...
 

Detailed Description

stl iterator over accepted clusters

Author
Markus Fasel marku.nosp@m.s.fa.nosp@m.sel@c.nosp@m.ern..nosp@m.ch, Lawrence Berkeley National Laboratory
Date
March 16, 2016

Bi-directional iterator over all accepted clusters in the array. The iterator is used in the standard way a c++ iterator is used. The container is responsible creating it. Afterwards one uses the prefix or postfix increment or decrement operator, depending on the direction of the iteration.

for(AliClusterContainer::iterator it = cont.accept_begin(); it != cont.accept_end(); ++cont){
std::cout << "Cluster energy: " << (*it)->E() std::endl; // do something with the cluster inside
}

As the postfix operator needs to perform a copy of the iterator, the prefix operator will have a better performance and should be preferred.

Note: This class is using a list of accepted clusters in the backend. This list is copied in the copy constructor and the assignment operator. Can be done in a more performant way using c++11 shared_ptr.

Definition at line 57 of file AliClusterContainer.h.

Constructor & Destructor Documentation

AliClusterContainer::accept_iterator::accept_iterator ( const AliClusterContainer cont,
int  start,
bool  forward = true 
)

Content of accept_iterator Constructor, inializing the iterator with

  • Cluster container to iterate over
  • Starting position for the iteration
  • Direction of the iteration (default: forward) This constructor also builds a lookup table of accepted clusters.

Note: Iterators should be created by the object it iterates over and not by hand.

Parameters
[in]contContainer to be iterated over (not modified)
[in]startStart position for the iteration
[in]forwardIf true iterator is a forward iterator

Definition at line 517 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator::accept_iterator ( const accept_iterator other)

Copy constructor. For the underlying container the pointer is copied.

Parameters
[in]otherReference for the copy

Definition at line 541 of file AliClusterContainer.cxx.

virtual AliClusterContainer::accept_iterator::~accept_iterator ( )
inlinevirtual

Definition at line 64 of file AliClusterContainer.h.

AliClusterContainer::accept_iterator::accept_iterator ( )
private

Member Function Documentation

bool AliClusterContainer::accept_iterator::operator!= ( const accept_iterator other) const

Comparison operator. The comparison is performed based on the current position of the iterator.

Parameters
[in]otherObject to compare to.
Returns
If true the positions of the two iterators match

Definition at line 571 of file AliClusterContainer.cxx.

AliVCluster * AliClusterContainer::accept_iterator::operator* ( ) const

Dereferencing operator. Providing access to the accepted cluster at the current position.

Returns
Accepted cluster at the given position (NULL if iterator is out of range)

Definition at line 632 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator & AliClusterContainer::accept_iterator::operator++ ( )

Incrementation prefix operator. Incrementing/Decrementing the postion of the iterator in the array based on the direction.

Returns
State of the iterator (reference) after iteration.

Definition at line 580 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator AliClusterContainer::accept_iterator::operator++ ( int  )

Incrementation postfix operator. Incrementing/Decrementing the postion of the iterator in the array based on the direction.

Parameters
[in]Notused, only defining the operator as postfix operator
Returns
State of the iterator (copy) before iteration

Definition at line 595 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator & AliClusterContainer::accept_iterator::operator-- ( )

Decrementation prefix operator. Decrementing/Incrementing the postion of the iterator in the array based on the direction.

Returns
State of the iterator (reference) after iteration.

Definition at line 606 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator AliClusterContainer::accept_iterator::operator-- ( int  )

Decrementation postfix operator. Decrementing/Incrementing the postion of the iterator in the array based on the direction.

Parameters
[in]Notused, only defining the operator as postfix operator
Returns
State of the iterator (copy) before iteration

Definition at line 621 of file AliClusterContainer.cxx.

AliClusterContainer::accept_iterator & AliClusterContainer::accept_iterator::operator= ( const accept_iterator other)

Assignmet operator, copying properties of the reference iterator

Parameters
[in]otherReference for the assignment
Returns
This object after the assingment

Definition at line 555 of file AliClusterContainer.cxx.

Member Data Documentation

TArrayI AliClusterContainer::accept_iterator::fAcceptIndices
private

Indices of accepted clusters.

Definition at line 79 of file AliClusterContainer.h.

Referenced by accept_iterator(), and operator=().

int AliClusterContainer::accept_iterator::fCurrentPos
private

Current position inside the container.

Definition at line 80 of file AliClusterContainer.h.

Referenced by operator!=(), and operator=().

bool AliClusterContainer::accept_iterator::fForward
private

Direction, expressed in forward direction.

Definition at line 81 of file AliClusterContainer.h.

Referenced by operator=().

const AliClusterContainer* AliClusterContainer::accept_iterator::fkContainer
private

Container iterated over.

Definition at line 78 of file AliClusterContainer.h.

Referenced by accept_iterator(), and operator=().


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