LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT > Class Template Reference

Internal helper class: actual implementation of nested iterator. More...

#include "NestedIterator.h"

Inheritance diagram for lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >:

Classes

struct  BeginPositionTag
 
struct  EndPositionTag
 

Public Types

using OuterIterator_t = ITER
 
using InnerContainerExtractor_t = INNERCONTEXTRACT
 
using InnerContainer_t = typename InnerContainerExtractor_t::result_type
 
using InnerIterator_t = typename InnerContainer_t::const_iterator
 
using iterator_type = deep_const_fwd_iterator_nested< OuterIterator_t, InnerContainerExtractor_t >
 
using value_type = typename InnerIterator_t::value_type
 Type of the value pointed by the iterator. More...
 

Public Member Functions

 deep_const_fwd_iterator_nested ()=default
 Default constructor: invalid iterator. More...
 
 deep_const_fwd_iterator_nested (OuterIterator_t src, OuterIterator_t end)
 Constructor: starts from the container at the specified iterator. More...
 
template<class CONT >
 deep_const_fwd_iterator_nested (const CONT &cont, BeginPositionTag)
 Constructor: starts from the beginning of the specified container. More...
 
template<class CONT >
 deep_const_fwd_iterator_nested (const CONT &cont, EndPositionTag)
 Constructor: starts from the end of the specified container. More...
 
iterator_typeoperator++ ()
 Prefix increment operator: points to the next element. More...
 
iterator_type operator++ (int)
 Postfix increment operator: points to the next element. More...
 
void swap (iterator_type &with)
 Swaps this with the specified iterator. More...
 
Dereference operators
const value_typeoperator* () const
 
const value_typeoperator-> () const
 
Comparison operators

Returns true if the two iterators are equivalent

bool operator== (const iterator_type &as) const
 Returns true if the two iterators are not equivalent. More...
 
bool operator!= (const iterator_type &as) const
 Returns true if the two iterators are not equivalent. More...
 
 operator bool () const
 Bonus: convert to bool to find out if we are at the end. More...
 
bool operator! () const
 Bonus: convert to bool to find out if we are at the end. More...
 

Static Public Attributes

static constexpr BeginPositionTag begin = {}
 
static constexpr EndPositionTag end = {}
 

Protected Member Functions

 deep_const_fwd_iterator_nested (OuterIterator_t end)
 Internal constructor: past-the-end iterator pointing to specified place. More...
 

Protected Attributes

OuterIterator_t outer_iter
 points to current inner container More...
 
OuterIterator_t outer_end
 points to past-the-end inner container More...
 
InnerIterator_t inner_iter
 points to the current element More...
 
InnerIterator_t inner_end
 stores the end of current inner container More...
 

Private Member Functions

void init_inner ()
 
void reset_inner ()
 
void skip_empty ()
 points to the next item More...
 
bool is_end () const
 
const InnerContainerExtractor_t::result_type & extract_container (const typename OuterIterator_t::value_type &v)
 Extracts the value out of the inner iterator. More...
 

Detailed Description

template<typename ITER, typename INNERCONTEXTRACT>
class lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >

Internal helper class: actual implementation of nested iterator.

Definition at line 59 of file NestedIterator.h.

Member Typedef Documentation

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::InnerContainer_t = typename InnerContainerExtractor_t::result_type

Definition at line 157 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::InnerContainerExtractor_t = INNERCONTEXTRACT

Definition at line 156 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::InnerIterator_t = typename InnerContainer_t::const_iterator

Definition at line 160 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::iterator_type = deep_const_fwd_iterator_nested <OuterIterator_t, InnerContainerExtractor_t>

Definition at line 164 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::OuterIterator_t = ITER

Definition at line 155 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
using lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::value_type = typename InnerIterator_t::value_type

Type of the value pointed by the iterator.

Definition at line 167 of file NestedIterator.h.

Constructor & Destructor Documentation

template<typename ITER, typename INNERCONTEXTRACT>
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::deep_const_fwd_iterator_nested ( )
default

Default constructor: invalid iterator.

This constructor sets the iterator in an invalid, end-of-container state.

template<typename ITER , typename INNERCONTEXTRACT >
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::deep_const_fwd_iterator_nested ( OuterIterator_t  src,
OuterIterator_t  end 
)

Constructor: starts from the container at the specified iterator.

Parameters
srcthe starting point of the iterator
endthe end point of the iterator

This constructor does not set and end. Due to how the class works, if the outer container has an "end", reaching it with this iterator has a undefined behaviour. You most likely want to use the constructor where you can also specify the end of the container.

Definition at line 323 of file NestedIterator.h.

323  :
324  outer_iter(src), outer_end(end)
325  {
326  if (is_end()) return;
327  init_inner();
328  skip_empty();
329  } // deep_const_fwd_iterator_nested(OuterIterator_t, OuterIterator_t)
OuterIterator_t outer_iter
points to current inner container
OuterIterator_t outer_end
points to past-the-end inner container
static constexpr EndPositionTag end
void skip_empty()
points to the next item
template<typename ITER, typename INNERCONTEXTRACT>
template<class CONT >
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::deep_const_fwd_iterator_nested ( const CONT &  cont,
BeginPositionTag   
)
inline

Constructor: starts from the beginning of the specified container.

Parameters
contthe container
[anonymous]tag to select the begin-of-container behaviour

The second parameter is used just to choose which constructor to use. Two constants are provided, begin and end, defined in the iterator itself (no explicit namespace is required). Example:

using Data_t = std::vector<std::vector<float>>;
Data_t data(5, { 1., 3., 5. });
deep_const_fwd_iterator_nested<Data_t::const_iterator> iData(data, begin),
data_end(data, end);

Definition at line 212 of file NestedIterator.h.

212  :
214  { skip_empty(); }
deep_const_fwd_iterator_nested()=default
Default constructor: invalid iterator.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void skip_empty()
points to the next item
template<typename ITER, typename INNERCONTEXTRACT>
template<class CONT >
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::deep_const_fwd_iterator_nested ( const CONT &  cont,
EndPositionTag   
)
inline

Constructor: starts from the end of the specified container.

Parameters
contthe container
[anonymous]tag to select the end-of-container behaviour

The second parameter is used just to choose which constructor to use. Two constants are provided, begin and end, defined in the iterator itself (no explicit namespace is required). Example:

using Data_t = std::vector<std::vector<float>>;
Data_t data(5, { 1., 3., 5. });
deep_const_fwd_iterator_nested<Data_t::const_iterator> iData(data, begin),
data_end(data, end);

Definition at line 233 of file NestedIterator.h.

233  :
deep_const_fwd_iterator_nested()=default
Default constructor: invalid iterator.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename ITER, typename INNERCONTEXTRACT>
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::deep_const_fwd_iterator_nested ( OuterIterator_t  end)
inlineprotected

Internal constructor: past-the-end iterator pointing to specified place.

Definition at line 298 of file NestedIterator.h.

298  :
deep_const_fwd_iterator_nested()=default
Default constructor: invalid iterator.
static constexpr EndPositionTag end

Member Function Documentation

template<typename ITER, typename INNERCONTEXTRACT>
const InnerContainerExtractor_t::result_type& lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::extract_container ( const typename OuterIterator_t::value_type &  v)
inlineprivate

Extracts the value out of the inner iterator.

Definition at line 310 of file NestedIterator.h.

311  { return InnerContainerExtractor_t()(v); }
template<typename ITER , typename INNERCONTEXTRACT >
void lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::init_inner ( )
private

Definition at line 353 of file NestedIterator.h.

References evd::details::begin(), and evd::details::end().

353  {
356  } // deep_const_fwd_iterator_nested<>::init_inner()
InnerIterator_t inner_iter
points to the current element
const InnerContainerExtractor_t::result_type & extract_container(const typename OuterIterator_t::value_type &v)
Extracts the value out of the inner iterator.
InnerIterator_t inner_end
stores the end of current inner container
OuterIterator_t outer_iter
points to current inner container
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename ITER, typename INNERCONTEXTRACT>
bool lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::is_end ( ) const
inlineprivate

Definition at line 306 of file NestedIterator.h.

Referenced by lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator!=(), and lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator==().

306 { return outer_iter == outer_end; }
OuterIterator_t outer_iter
points to current inner container
OuterIterator_t outer_end
points to past-the-end inner container
template<typename ITER, typename INNERCONTEXTRACT>
lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator bool ( ) const
inline

Bonus: convert to bool to find out if we are at the end.

Returns
whether this operator is past-the-end

Definition at line 283 of file NestedIterator.h.

283 { return !is_end(); }
template<typename ITER, typename INNERCONTEXTRACT>
bool lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator! ( ) const
inline

Bonus: convert to bool to find out if we are at the end.

Returns
whether this operator is past-the-end

Definition at line 284 of file NestedIterator.h.

284 { return is_end(); }
template<typename ITER, typename INNERCONTEXTRACT>
bool lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator!= ( const iterator_type as) const
inline

Returns true if the two iterators are not equivalent.

Definition at line 270 of file NestedIterator.h.

References lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::inner_iter, lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::is_end(), and lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::outer_iter.

271  {
272  return (as.outer_iter != outer_iter)
273  || ((as.inner_iter != inner_iter) && (!is_end() || !as.is_end()));
274  }
InnerIterator_t inner_iter
points to the current element
OuterIterator_t outer_iter
points to current inner container
template<typename ITER, typename INNERCONTEXTRACT>
const value_type& lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator* ( ) const
inline

Definition at line 257 of file NestedIterator.h.

257 { return *inner_iter; }
InnerIterator_t inner_iter
points to the current element
template<typename ITER , typename INNERCONTEXTRACT >
deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT > & lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator++ ( )

Prefix increment operator: points to the next element.

Returns
this iterator, already incremented

The behaviour of this method on a past-the-end iterator is undefined (currently, chances are it will access invalid memory).

Definition at line 334 of file NestedIterator.h.

334  {
335  ++inner_iter;
336  skip_empty();
337  return *this;
338  } // deep_const_fwd_iterator_nested<>::operator++()
InnerIterator_t inner_iter
points to the current element
void skip_empty()
points to the next item
template<typename ITER, typename INNERCONTEXTRACT>
iterator_type lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator++ ( int  )
inline

Postfix increment operator: points to the next element.

Returns
a copy of this iterator before the increment

The behaviour of this method on a past-the-end iterator is undefined (currently, chances are it will access invalid memory).

Definition at line 252 of file NestedIterator.h.

253  { iterator_type old(*this); this->operator++(); return old; }
iterator_type & operator++()
Prefix increment operator: points to the next element.
deep_const_fwd_iterator_nested< OuterIterator_t, InnerContainerExtractor_t > iterator_type
template<typename ITER, typename INNERCONTEXTRACT>
const value_type& lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator-> ( ) const
inline

Definition at line 258 of file NestedIterator.h.

258 { return *inner_iter; }
InnerIterator_t inner_iter
points to the current element
template<typename ITER, typename INNERCONTEXTRACT>
bool lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::operator== ( const iterator_type as) const
inline

Returns true if the two iterators are not equivalent.

Definition at line 264 of file NestedIterator.h.

References lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::inner_iter, lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::is_end(), and lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::outer_iter.

265  {
266  return (as.outer_iter == outer_iter)
267  && ((as.inner_iter == inner_iter) || (is_end() && as.is_end()));
268  }
InnerIterator_t inner_iter
points to the current element
OuterIterator_t outer_iter
points to current inner container
template<typename ITER , typename INNERCONTEXTRACT >
void lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::reset_inner ( )
private

Definition at line 360 of file NestedIterator.h.

361  { inner_end = inner_iter = {}; }
InnerIterator_t inner_iter
points to the current element
InnerIterator_t inner_end
stores the end of current inner container
template<typename ITER , typename INNERCONTEXTRACT >
void lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::skip_empty ( )
private

points to the next item

Definition at line 364 of file NestedIterator.h.

364  {
365  while(inner_iter == inner_end) {
366  ++outer_iter;
367  if (is_end()) {
368  reset_inner();
369  return;
370  } // if
371  init_inner();
372  } // while inner iterator ended
373  } // skip_empty()
InnerIterator_t inner_iter
points to the current element
InnerIterator_t inner_end
stores the end of current inner container
OuterIterator_t outer_iter
points to current inner container
template<typename ITER , typename INNERCONTEXTRACT >
void lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::swap ( iterator_type with)

Swaps this with the specified iterator.

Definition at line 343 of file NestedIterator.h.

References lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::inner_end, lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::inner_iter, lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::outer_end, and lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::outer_iter.

Referenced by std::swap().

344  {
345  std::swap(outer_iter, with.outer_iter);
346  std::swap(outer_end, with.outer_end);
347  std::swap(inner_iter, with.inner_iter);
348  std::swap(inner_end, with.inner_end);
349  } // deep_const_fwd_iterator_nested<>::swap()
InnerIterator_t inner_iter
points to the current element
InnerIterator_t inner_end
stores the end of current inner container
OuterIterator_t outer_iter
points to current inner container
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
OuterIterator_t outer_end
points to past-the-end inner container

Member Data Documentation

template<typename ITER, typename INNERCONTEXTRACT>
constexpr BeginPositionTag lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::begin = {}
static

Definition at line 173 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
constexpr EndPositionTag lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::end = {}
static

Definition at line 174 of file NestedIterator.h.

template<typename ITER, typename INNERCONTEXTRACT>
InnerIterator_t lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::inner_end
protected

stores the end of current inner container

Definition at line 295 of file NestedIterator.h.

Referenced by lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::swap().

template<typename ITER, typename INNERCONTEXTRACT>
OuterIterator_t lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::outer_end
protected

points to past-the-end inner container

Definition at line 292 of file NestedIterator.h.

Referenced by lar::deep_const_fwd_iterator_nested< ITER, INNERCONTEXTRACT >::swap().


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