LDMX Software
Public Member Functions | Private Attributes | List of all members
ldmx::HgcrocDigiCollection::iterator Class Reference

iterator class so we can do range-based loops over digi collections More...

#include <HgcrocDigiCollection.h>

Public Member Functions

 iterator (HgcrocDigiCollection &c, long index=0)
 Connect the parent collection with an index to this iterator.
 
iteratoroperator++ ()
 Increment the digi index and return the iterator afterwards.
 
iterator operator++ (int)
 Increment the digi index and return the iterator before.
 
bool operator== (iterator other) const
 Check if two iterators are on the same index.
 
bool operator!= (iterator other) const
 Check if two iterators are not on the same index.
 
const HgcrocDigi operator* () const
 De-reference this iterator by using the parent collection to get the actual digi at the index.
 

Private Attributes

long digi_index_ {0}
 the index of the digi this iterator represents
 
HgcrocDigiCollectioncoll_
 the parent collection this iterator is looping over
 

Detailed Description

iterator class so we can do range-based loops over digi collections

We inherit from the standard iterator class and tag this iterator as one that de-references to an HgcrocDigi.

Internally, we are merely keeping track of the index of the digi in the collection and only getting the digi when the iterator is asked to de-reference.

Definition at line 440 of file HgcrocDigiCollection.h.

Constructor & Destructor Documentation

◆ iterator()

ldmx::HgcrocDigiCollection::iterator::iterator ( HgcrocDigiCollection c,
long  index = 0 
)
inlineexplicit

Connect the parent collection with an index to this iterator.

Definition at line 444 of file HgcrocDigiCollection.h.

445 : digi_index_{index}, coll_{c} {}
long digi_index_
the index of the digi this iterator represents
HgcrocDigiCollection & coll_
the parent collection this iterator is looping over

Member Function Documentation

◆ operator!=()

bool ldmx::HgcrocDigiCollection::iterator::operator!= ( iterator  other) const
inline

Check if two iterators are not on the same index.

Definition at line 462 of file HgcrocDigiCollection.h.

462{ return !(*this == other); }

◆ operator*()

const HgcrocDigi ldmx::HgcrocDigiCollection::iterator::operator* ( ) const
inline

De-reference this iterator by using the parent collection to get the actual digi at the index.

Definition at line 467 of file HgcrocDigiCollection.h.

467{ return coll_.getDigi(digi_index_); }
const HgcrocDigi getDigi(unsigned int digiIndex) const
Get samples for the input digi index.

References coll_, digi_index_, and ldmx::HgcrocDigiCollection::getDigi().

◆ operator++() [1/2]

iterator & ldmx::HgcrocDigiCollection::iterator::operator++ ( )
inline

Increment the digi index and return the iterator afterwards.

Definition at line 447 of file HgcrocDigiCollection.h.

447 {
448 digi_index_++;
449 return *this;
450 }

References digi_index_.

◆ operator++() [2/2]

iterator ldmx::HgcrocDigiCollection::iterator::operator++ ( int  )
inline

Increment the digi index and return the iterator before.

Definition at line 452 of file HgcrocDigiCollection.h.

452 {
453 iterator retval = *this;
454 ++(*this);
455 return retval;
456 }
iterator(HgcrocDigiCollection &c, long index=0)
Connect the parent collection with an index to this iterator.

◆ operator==()

bool ldmx::HgcrocDigiCollection::iterator::operator== ( iterator  other) const
inline

Check if two iterators are on the same index.

Definition at line 458 of file HgcrocDigiCollection.h.

458 {
459 return digi_index_ == other.digi_index_;
460 }

References digi_index_.

Member Data Documentation

◆ coll_

HgcrocDigiCollection& ldmx::HgcrocDigiCollection::iterator::coll_
private

the parent collection this iterator is looping over

Definition at line 473 of file HgcrocDigiCollection.h.

Referenced by operator*().

◆ digi_index_

long ldmx::HgcrocDigiCollection::iterator::digi_index_ {0}
private

the index of the digi this iterator represents

Definition at line 471 of file HgcrocDigiCollection.h.

471{0};

Referenced by operator*(), operator++(), and operator==().


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