LDMX Software
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 443 of file HgcrocDigiCollection.h.

444 : 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 461 of file HgcrocDigiCollection.h.

461{ 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 466 of file HgcrocDigiCollection.h.

466{ 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 446 of file HgcrocDigiCollection.h.

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

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 451 of file HgcrocDigiCollection.h.

451 {
452 iterator retval = *this;
453 ++(*this);
454 return retval;
455 }
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 457 of file HgcrocDigiCollection.h.

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

References digi_index_.

Member Data Documentation

◆ coll_

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

the parent collection this iterator is looping over

Definition at line 472 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 470 of file HgcrocDigiCollection.h.

470{0};

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


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