LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
proxy::details::IndexBasedIterator< Cont > Class Template Reference

Iterator to random access collection storing a current index. More...

#include "CollectionProxy.h"

Public Types

using container_t = Cont
 
using value_type = util::collection_value_t< container_t >
 
using const_iterator = IndexBasedIterator
 

Public Member Functions

 IndexBasedIterator ()=default
 Default constructor (required by iterator protocol): an unusable iterator. More...
 
 IndexBasedIterator (container_t const &cont, std::size_t index=0)
 Constructor: initializes from an iterator of the proxy main collection. More...
 
auto operator* () const -> decltype(auto)
 Returns the value pointed by this iterator. More...
 
const_iteratoroperator++ ()
 Returns the value pointed by this iterator. More...
 
bool operator!= (const_iterator const &other) const
 Returns whether the iterators point to the same element. More...
 

Protected Attributes

container_t const * fCont = nullptr
 Pointer to the original container. More...
 
std::size_t fIndex = std::numeric_limits<std::size_t>::max()
 Current index in the main collection. More...
 

Detailed Description

template<typename Cont>
class proxy::details::IndexBasedIterator< Cont >

Iterator to random access collection storing a current index.

Template Parameters
Conttype of random-access container to iterate

Cont is a type providing a public operator[](std::size_t) method.

Definition at line 32 of file CollectionProxy.h.

Member Typedef Documentation

template<typename Cont >
using proxy::details::IndexBasedIterator< Cont >::const_iterator = IndexBasedIterator

Definition at line 338 of file CollectionProxy.h.

template<typename Cont >
using proxy::details::IndexBasedIterator< Cont >::container_t = Cont

Definition at line 335 of file CollectionProxy.h.

Definition at line 337 of file CollectionProxy.h.

Constructor & Destructor Documentation

template<typename Cont >
proxy::details::IndexBasedIterator< Cont >::IndexBasedIterator ( )
default

Default constructor (required by iterator protocol): an unusable iterator.

template<typename Cont >
proxy::details::IndexBasedIterator< Cont >::IndexBasedIterator ( container_t const &  cont,
std::size_t  index = 0 
)
inline

Constructor: initializes from an iterator of the proxy main collection.

Definition at line 344 of file CollectionProxy.h.

345  : fCont(&cont), fIndex(index)
346  {}
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.

Member Function Documentation

template<typename Cont >
bool proxy::details::IndexBasedIterator< Cont >::operator!= ( const_iterator const &  other) const
inline

Returns whether the iterators point to the same element.

Definition at line 359 of file CollectionProxy.h.

References proxy::details::IndexBasedIterator< Cont >::fCont, and proxy::details::IndexBasedIterator< Cont >::fIndex.

360  {
361  return (other.fIndex != fIndex) || (other.fCont != fCont);
362  }
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.
template<typename Cont >
auto proxy::details::IndexBasedIterator< Cont >::operator* ( ) const -> decltype(auto)
inline

Returns the value pointed by this iterator.

Definition at line 349 of file CollectionProxy.h.

349 { return fCont->operator[](fIndex); }
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.
template<typename Cont >
const_iterator& proxy::details::IndexBasedIterator< Cont >::operator++ ( )
inline

Returns the value pointed by this iterator.

Definition at line 352 of file CollectionProxy.h.

353  {
354  ++fIndex;
355  return *this;
356  }
std::size_t fIndex
Current index in the main collection.

Member Data Documentation

template<typename Cont >
container_t const* proxy::details::IndexBasedIterator< Cont >::fCont = nullptr
protected

Pointer to the original container.

Definition at line 365 of file CollectionProxy.h.

Referenced by proxy::details::IndexBasedIterator< Cont >::operator!=().

template<typename Cont >
std::size_t proxy::details::IndexBasedIterator< Cont >::fIndex = std::numeric_limits<std::size_t>::max()
protected

Current index in the main collection.

Definition at line 368 of file CollectionProxy.h.

Referenced by proxy::details::IndexBasedIterator< Cont >::operator!=().


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