LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::value_const_iterator< T > Class Template Reference

A constant iterator returning always the same value. More...

#include "sparse_vector.h"

Public Types

using iterator_category = std::random_access_iterator_tag
 
using value_type = T
 
using difference_type = std::ptrdiff_t
 
using pointer = T *
 
using reference = T &
 

Public Member Functions

 value_const_iterator ()
 Default constructor: use the default value. More...
 
 value_const_iterator (value_type new_value)
 Constructor: value that will be returned. More...
 
 value_const_iterator (value_type new_value, difference_type offset)
 Constructor: value to be returned and current iterator "position". More...
 
value_type operator* () const
 Returns a copy of the stored value. More...
 
value_type operator[] (difference_type) const
 Returns a copy of the stored value. More...
 
this_toperator++ ()
 Increments the position of the iterator, returns the new position. More...
 
this_t operator++ (int)
 Increments the position of the iterator, returns the old position. More...
 
this_toperator-- ()
 Decrements the position of the iterator, returns the new position. More...
 
this_t operator-- (int)
 Decrements the position of the iterator, returns the old position. More...
 
this_toperator+= (difference_type ofs)
 Increments the position of the iterator by the specified steps. More...
 
this_toperator-= (difference_type ofs)
 Decrements the position of the iterator by the specified steps. More...
 
this_t operator+ (difference_type ofs) const
 Returns an iterator pointing ahead of this one by the specified steps. More...
 
this_t operator- (difference_type ofs) const
 Returns an iterator pointing behind this one by the specified steps. More...
 
difference_type operator- (const this_t &iter) const
 Returns the distance between this iterator and the other. More...
 
bool operator== (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 
bool operator!= (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 
bool operator< (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 
bool operator<= (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 
bool operator> (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 
bool operator>= (const this_t &as) const
 Comparison operators: determined by the position pointed by the iterators. More...
 

Protected Attributes

difference_type index {0}
 (arbitrary) position pointed by the iterator More...
 
value_type value
 value to be returned when dereferencing More...
 

Private Types

typedef value_const_iterator< T > this_t
 alias for this type More...
 

Detailed Description

template<typename T>
class lar::value_const_iterator< T >

A constant iterator returning always the same value.

Template Parameters
Ttype of the value returned by dereferenciation

Definition at line 67 of file sparse_vector.h.

Member Typedef Documentation

template<typename T>
using lar::value_const_iterator< T >::difference_type = std::ptrdiff_t

Definition at line 73 of file sparse_vector.h.

template<typename T>
using lar::value_const_iterator< T >::iterator_category = std::random_access_iterator_tag

Definition at line 71 of file sparse_vector.h.

template<typename T>
using lar::value_const_iterator< T >::pointer = T*

Definition at line 74 of file sparse_vector.h.

template<typename T>
using lar::value_const_iterator< T >::reference = T&

Definition at line 75 of file sparse_vector.h.

template<typename T>
typedef value_const_iterator<T> lar::value_const_iterator< T >::this_t
private

alias for this type

Definition at line 68 of file sparse_vector.h.

template<typename T>
using lar::value_const_iterator< T >::value_type = T

Definition at line 72 of file sparse_vector.h.

Constructor & Destructor Documentation

template<typename T>
lar::value_const_iterator< T >::value_const_iterator ( )
inline

Default constructor: use the default value.

Definition at line 78 of file sparse_vector.h.

78 : value() {}
value_type value
value to be returned when dereferencing
template<typename T>
lar::value_const_iterator< T >::value_const_iterator ( value_type  new_value)
inline

Constructor: value that will be returned.

Definition at line 81 of file sparse_vector.h.

81 : value(new_value) {}
value_type value
value to be returned when dereferencing
template<typename T>
lar::value_const_iterator< T >::value_const_iterator ( value_type  new_value,
difference_type  offset 
)
inline

Constructor: value to be returned and current iterator "position".

Definition at line 84 of file sparse_vector.h.

85  : index(offset), value(new_value)
86  {}
value_type value
value to be returned when dereferencing
difference_type index
(arbitrary) position pointed by the iterator

Member Function Documentation

template<typename T>
bool lar::value_const_iterator< T >::operator!= ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 151 of file sparse_vector.h.

References lar::value_const_iterator< T >::index.

151 { return index != as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
value_type lar::value_const_iterator< T >::operator* ( ) const
inline

Returns a copy of the stored value.

Definition at line 89 of file sparse_vector.h.

References lar::const_value_box< T >::value.

89 { return value; }
value_type value
value to be returned when dereferencing
template<typename T>
this_t lar::value_const_iterator< T >::operator+ ( difference_type  ofs) const
inline

Returns an iterator pointing ahead of this one by the specified steps.

Definition at line 139 of file sparse_vector.h.

References lar::const_value_box< T >::value.

139 { return this_t(value, index + ofs); }
value_type value
value to be returned when dereferencing
difference_type index
(arbitrary) position pointed by the iterator
value_const_iterator< T > this_t
alias for this type
Definition: sparse_vector.h:68
template<typename T>
this_t& lar::value_const_iterator< T >::operator++ ( )
inline

Increments the position of the iterator, returns the new position.

Definition at line 95 of file sparse_vector.h.

96  {
97  ++index;
98  return *this;
99  }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
this_t lar::value_const_iterator< T >::operator++ ( int  )
inline

Increments the position of the iterator, returns the old position.

Definition at line 102 of file sparse_vector.h.

103  {
104  this_t copy(*this);
105  ++index;
106  return copy;
107  }
difference_type index
(arbitrary) position pointed by the iterator
value_const_iterator< T > this_t
alias for this type
Definition: sparse_vector.h:68
template<typename T>
this_t& lar::value_const_iterator< T >::operator+= ( difference_type  ofs)
inline

Increments the position of the iterator by the specified steps.

Definition at line 125 of file sparse_vector.h.

126  {
127  index += ofs;
128  return *this;
129  }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
this_t lar::value_const_iterator< T >::operator- ( difference_type  ofs) const
inline

Returns an iterator pointing behind this one by the specified steps.

Definition at line 142 of file sparse_vector.h.

References lar::const_value_box< T >::value.

142 { return this_t(value, index - ofs); }
value_type value
value to be returned when dereferencing
difference_type index
(arbitrary) position pointed by the iterator
value_const_iterator< T > this_t
alias for this type
Definition: sparse_vector.h:68
template<typename T>
difference_type lar::value_const_iterator< T >::operator- ( const this_t iter) const
inline

Returns the distance between this iterator and the other.

Returns
how many steps this iterator is ahead of the other

Definition at line 146 of file sparse_vector.h.

References lar::value_const_iterator< T >::index, and util::details::operator==().

146 { return index - iter.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
this_t& lar::value_const_iterator< T >::operator-- ( )
inline

Decrements the position of the iterator, returns the new position.

Definition at line 110 of file sparse_vector.h.

111  {
112  --index;
113  return *this;
114  }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
this_t lar::value_const_iterator< T >::operator-- ( int  )
inline

Decrements the position of the iterator, returns the old position.

Definition at line 117 of file sparse_vector.h.

118  {
119  this_t copy(*this);
120  --index;
121  return copy;
122  }
difference_type index
(arbitrary) position pointed by the iterator
value_const_iterator< T > this_t
alias for this type
Definition: sparse_vector.h:68
template<typename T>
this_t& lar::value_const_iterator< T >::operator-= ( difference_type  ofs)
inline

Decrements the position of the iterator by the specified steps.

Definition at line 132 of file sparse_vector.h.

133  {
134  index -= ofs;
135  return *this;
136  }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
bool lar::value_const_iterator< T >::operator< ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 153 of file sparse_vector.h.

References lar::value_const_iterator< T >::index.

153 { return index < as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
bool lar::value_const_iterator< T >::operator<= ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 154 of file sparse_vector.h.

References lar::value_const_iterator< T >::index.

154 { return index <= as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
bool lar::value_const_iterator< T >::operator== ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 150 of file sparse_vector.h.

150 { return index == as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
bool lar::value_const_iterator< T >::operator> ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 155 of file sparse_vector.h.

References lar::value_const_iterator< T >::index.

155 { return index > as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
bool lar::value_const_iterator< T >::operator>= ( const this_t as) const
inline

Comparison operators: determined by the position pointed by the iterators.

Definition at line 156 of file sparse_vector.h.

References lar::value_const_iterator< T >::index.

156 { return index >= as.index; }
difference_type index
(arbitrary) position pointed by the iterator
template<typename T>
value_type lar::value_const_iterator< T >::operator[] ( difference_type  ) const
inline

Returns a copy of the stored value.

Definition at line 92 of file sparse_vector.h.

References lar::const_value_box< T >::value.

92 { return value; }
value_type value
value to be returned when dereferencing

Member Data Documentation

template<typename T>
value_type lar::value_const_iterator< T >::value
protected

value to be returned when dereferencing

Definition at line 161 of file sparse_vector.h.

Referenced by lar::operator+().


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