Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
WireCell::RandomIter< Container, Value > Struct Template Reference

#include <RandomIter.h>

Inheritance diagram for WireCell::RandomIter< Container, Value >:

Public Member Functions

 RandomIter (Container &array)
 
 RandomIter (bool, Container &array)
 

Private Types

typedef boost::iterator_facade< RandomIter< Container, Value >, Value, boost::random_access_traversal_tag > facade
 

Private Member Functions

bool equal (RandomIter< Container, Value > const &other) const
 
facade::difference_type distance_to (RandomIter const &other) const
 
void advance (typename facade::difference_type n)
 
void increment ()
 
void decrement ()
 
Valuedereference () const
 

Private Attributes

Container & m_array
 
int m_index
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<typename Container, typename Value>
struct WireCell::RandomIter< Container, Value >

Definition at line 10 of file RandomIter.h.

Member Typedef Documentation

template<typename Container, typename Value>
typedef boost::iterator_facade< RandomIter<Container, Value>, Value, boost::random_access_traversal_tag > WireCell::RandomIter< Container, Value >::facade
private

Definition at line 43 of file RandomIter.h.

Constructor & Destructor Documentation

template<typename Container, typename Value>
WireCell::RandomIter< Container, Value >::RandomIter ( Container &  array)
inlineexplicit

Definition at line 17 of file RandomIter.h.

18  : m_array(array)
19  , m_index(0)
20  {}
Container & m_array
Definition: RandomIter.h:31
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
template<typename Container, typename Value>
WireCell::RandomIter< Container, Value >::RandomIter ( bool  ,
Container &  array 
)
inlineexplicit

Definition at line 23 of file RandomIter.h.

24  : m_array(array)
25  , m_index(array.size())
26  {}
Container & m_array
Definition: RandomIter.h:31
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228

Member Function Documentation

template<typename Container, typename Value>
void WireCell::RandomIter< Container, Value >::advance ( typename facade::difference_type  n)
inlineprivate

Definition at line 48 of file RandomIter.h.

49  {
50  m_index += n;
51  if (m_index >= (int)m_array.size() || m_index < 0) {
52  m_index = m_array.size();
53  }
54  }
Container & m_array
Definition: RandomIter.h:31
std::size_t n
Definition: format.h:3399
template<typename Container, typename Value>
void WireCell::RandomIter< Container, Value >::decrement ( )
inlineprivate

Definition at line 60 of file RandomIter.h.

60  {
61  advance(-1);
62  }
void advance(typename facade::difference_type n)
Definition: RandomIter.h:48
template<typename Container, typename Value>
Value& WireCell::RandomIter< Container, Value >::dereference ( ) const
inlineprivate

Definition at line 65 of file RandomIter.h.

65  {
66  return m_array.at(m_index);
67  }
Container & m_array
Definition: RandomIter.h:31
template<typename Container, typename Value>
facade::difference_type WireCell::RandomIter< Container, Value >::distance_to ( RandomIter< Container, Value > const &  other) const
inlineprivate

Definition at line 44 of file RandomIter.h.

44  {
45  return other.m_index - this->m_index;
46  }
template<typename Container, typename Value>
bool WireCell::RandomIter< Container, Value >::equal ( RandomIter< Container, Value > const &  other) const
inlineprivate

Definition at line 34 of file RandomIter.h.

35  {
36  return this->m_index == other.m_index;
37  }
template<typename Container, typename Value>
void WireCell::RandomIter< Container, Value >::increment ( )
inlineprivate

Definition at line 56 of file RandomIter.h.

56  {
57  advance(1);
58  }
void advance(typename facade::difference_type n)
Definition: RandomIter.h:48

Friends And Related Function Documentation

template<typename Container, typename Value>
friend class boost::iterator_core_access
friend

Definition at line 29 of file RandomIter.h.

Member Data Documentation

template<typename Container, typename Value>
Container& WireCell::RandomIter< Container, Value >::m_array
private

Definition at line 31 of file RandomIter.h.

template<typename Container, typename Value>
int WireCell::RandomIter< Container, Value >::m_index
private

Definition at line 32 of file RandomIter.h.


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