LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar::sparse_vector< T >::iterator Class Reference

Iterator to the sparse vector values. More...

#include "sparse_vector.h"

Inheritance diagram for lar::sparse_vector< T >::iterator:
lar::sparse_vector< T >::const_iterator

Public Types

typedef const_iterator::reference reference
 
typedef const_iterator::const_reference const_reference
 
typedef const_iterator::special special
 
typedef std::forward_iterator_tag iterator_category
 
typedef container_t::value_type value_type
 
typedef container_t::difference_type difference_type
 
typedef container_t::pointer pointer
 

Public Member Functions

 iterator ()
 Default constructor, does not iterate anywhere. More...
 
 iterator (container_t &c, size_type offset=0)
 Constructor from a container and an offset. More...
 
 iterator (const container_t &c, const typename special::begin _)
 Special constructor: initializes at the beginning of the container. More...
 
 iterator (const container_t &c, const typename special::end _)
 Special constructor: initializes at the end of the container. More...
 
reference operator[] (size_type offset) const
 Random access. More...
 
reference operator* () const
 Dereferenciation operator (can't write non-empty elements!) More...
 
difference_type operator- (const const_iterator &iter) const
 Distance operator. More...
 
range_const_iterator get_current_range () const
 Returns the current range internal value; use it at your own risk!! More...
 
iteratoroperator++ ()
 Increment and decrement operators. More...
 
iterator operator++ (int _)
 Increment and decrement operators. More...
 
iteratoroperator+= (difference_type delta)
 Increment and decrement operators. More...
 
iteratoroperator-= (difference_type delta)
 Increment and decrement operators. More...
 
iterator operator+ (difference_type delta) const
 Increment and decrement operators. More...
 
iterator operator- (difference_type delta) const
 Increment and decrement operators. More...
 
bool operator== (const const_iterator &as) const
 Iterator comparisons. More...
 
bool operator!= (const const_iterator &as) const
 Iterator comparisons. More...
 
bool operator< (const const_iterator &than) const
 Iterator comparisons. More...
 
bool operator> (const const_iterator &than) const
 Iterator comparisons. More...
 
bool operator<= (const const_iterator &than) const
 Iterator comparisons. More...
 
bool operator>= (const const_iterator &than) const
 Iterator comparisons. More...
 

Protected Types

typedef container_t::size_type size_type
 
typedef container_t::range_list_t::const_iterator ranges_const_iterator
 

Protected Member Functions

 iterator (const_iterator from)
 
void refresh_state ()
 Reassigns the internal state according to the index. More...
 

Protected Attributes

const container_tcont
 pointer to the container More...
 
size_type index
 pointer to the current value, as absolute index More...
 
ranges_const_iterator currentRange
 pointer to the current (or next) range More...
 

Private Types

typedef const_iterator::container_t container_t
 

Detailed Description

template<typename T>
class lar::sparse_vector< T >::iterator

Iterator to the sparse vector values.

This iterator respects the traits of an immutable forward iterator, EXCEPT that the iterator can be non-dereferenciable even when it's a "past the end" iterator. That is due to the fact that currently dereferencing (and assigning) to a cell which is not in a range already is not supported yet (it can be done with some complicate mechanism).

Definition at line 1293 of file sparse_vector.h.

Member Typedef Documentation

template<typename T>
typedef const_iterator::const_reference lar::sparse_vector< T >::iterator::const_reference

Definition at line 1299 of file sparse_vector.h.

template<typename T>
typedef const_iterator::container_t lar::sparse_vector< T >::iterator::container_t
private

Definition at line 1294 of file sparse_vector.h.

template<typename T>
typedef container_t::difference_type lar::sparse_vector< T >::const_iterator::difference_type
inherited

Definition at line 1170 of file sparse_vector.h.

template<typename T>
typedef std::forward_iterator_tag lar::sparse_vector< T >::const_iterator::iterator_category
inherited

Definition at line 1160 of file sparse_vector.h.

template<typename T>
typedef container_t::pointer lar::sparse_vector< T >::const_iterator::pointer
inherited

Definition at line 1171 of file sparse_vector.h.

template<typename T>
typedef container_t::range_list_t::const_iterator lar::sparse_vector< T >::const_iterator::ranges_const_iterator
protectedinherited

Definition at line 1154 of file sparse_vector.h.

template<typename T>
typedef const_iterator::reference lar::sparse_vector< T >::iterator::reference

Definition at line 1298 of file sparse_vector.h.

template<typename T>
typedef container_t::size_type lar::sparse_vector< T >::const_iterator::size_type
protectedinherited

Definition at line 1153 of file sparse_vector.h.

template<typename T>
typedef const_iterator::special lar::sparse_vector< T >::iterator::special

Definition at line 1300 of file sparse_vector.h.

template<typename T>
typedef container_t::value_type lar::sparse_vector< T >::const_iterator::value_type
inherited

Definition at line 1169 of file sparse_vector.h.

Constructor & Destructor Documentation

template<typename T>
lar::sparse_vector< T >::iterator::iterator ( )
inline

Default constructor, does not iterate anywhere.

Definition at line 1303 of file sparse_vector.h.

1303 : const_iterator() {}
const_iterator()
Default constructor, does not iterate anywhere.
template<typename T>
lar::sparse_vector< T >::iterator::iterator ( container_t c,
size_type  offset = 0 
)
inline

Constructor from a container and an offset.

Definition at line 1306 of file sparse_vector.h.

1306  :
1307  const_iterator(c, offset) {}
const_iterator()
Default constructor, does not iterate anywhere.
template<typename T>
lar::sparse_vector< T >::iterator::iterator ( const container_t c,
const typename special::begin  _ 
)
inline

Special constructor: initializes at the beginning of the container.

Definition at line 1310 of file sparse_vector.h.

1310  :
1311  const_iterator(c, _) {}
const_iterator()
Default constructor, does not iterate anywhere.
template<typename T>
lar::sparse_vector< T >::iterator::iterator ( const container_t c,
const typename special::end  _ 
)
inline

Special constructor: initializes at the end of the container.

Definition at line 1314 of file sparse_vector.h.

1314  :
1315  const_iterator(c, _) {}
const_iterator()
Default constructor, does not iterate anywhere.
template<typename T>
lar::sparse_vector< T >::iterator::iterator ( const_iterator  from)
inlineprotected

Definition at line 1351 of file sparse_vector.h.

1351 : const_iterator(from) {}
const_iterator()
Default constructor, does not iterate anywhere.

Member Function Documentation

template<typename T>
range_const_iterator lar::sparse_vector< T >::const_iterator::get_current_range ( ) const
inlineinherited

Returns the current range internal value; use it at your own risk!!

Definition at line 1239 of file sparse_vector.h.

Referenced by lar::sparse_vector< T >::make_void().

1239 { return currentRange; }
ranges_const_iterator currentRange
pointer to the current (or next) range
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator!= ( const const_iterator as) const
inlineinherited

Iterator comparisons.

Definition at line 1226 of file sparse_vector.h.

References lar::sparse_vector< T >::const_iterator::cont, and lar::sparse_vector< T >::const_iterator::index.

1227  { return (cont != as.cont) || (index != as.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
reference lar::sparse_vector< T >::iterator::operator* ( ) const
inline

Dereferenciation operator (can't write non-empty elements!)

Definition at line 1341 of file sparse_vector.h.

1342  { return reference(const_iterator::operator*()); }
const_iterator::reference reference
template<typename T>
iterator lar::sparse_vector< T >::iterator::operator+ ( difference_type  delta) const
inline

Increment and decrement operators.

Definition at line 1333 of file sparse_vector.h.

References operator+().

1334  { return const_iterator::operator+(delta); }
const_iterator operator+(difference_type delta) const
Increment and decrement operators.
template<typename T>
iterator& lar::sparse_vector< T >::iterator::operator++ ( )
inline

Increment and decrement operators.

Definition at line 1323 of file sparse_vector.h.

1323 { const_iterator::operator++(); return *this; }
const_iterator & operator++()
Increment and decrement operators.
template<typename T>
iterator lar::sparse_vector< T >::iterator::operator++ ( int  _)
inline

Increment and decrement operators.

Definition at line 1324 of file sparse_vector.h.

References shims::map< Key, T, Compare, Allocator >::iter< Category, TT, Distance, Pointer, Reference >::operator++(), and lar::dump::operator+=().

1324 { return const_iterator::operator++(_); }
const_iterator & operator++()
Increment and decrement operators.
template<typename T>
iterator& lar::sparse_vector< T >::iterator::operator+= ( difference_type  delta)
inline

Increment and decrement operators.

Definition at line 1329 of file sparse_vector.h.

1330  { const_iterator::operator+=(delta); return *this; }
const_iterator & operator+=(difference_type delta)
Increment and decrement operators.
template<typename T >
lar::sparse_vector< T >::const_iterator::difference_type lar::sparse_vector< T >::const_iterator::operator- ( const const_iterator iter) const
inlineinherited

Distance operator.

distance operator

Definition at line 1968 of file sparse_vector.h.

1969 {
1970  if (cont != iter.cont) {
1971  throw std::runtime_error("lar::sparse_vector::const_iterator:"
1972  " difference with alien iterator");
1973  }
1974  return index -iter.index;
1975 } // lar::sparse_vector<T>::const_iterator::operator-(const_iterator)
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
iterator lar::sparse_vector< T >::iterator::operator- ( difference_type  delta) const
inline

Increment and decrement operators.

Definition at line 1335 of file sparse_vector.h.

References operator-().

1336  { return const_iterator::operator-(delta); }
const_iterator operator-(difference_type delta) const
Increment and decrement operators.
template<typename T>
iterator& lar::sparse_vector< T >::iterator::operator-= ( difference_type  delta)
inline

Increment and decrement operators.

Definition at line 1331 of file sparse_vector.h.

References lar::dump::operator+=().

1332  { const_iterator::operator+=(delta); return *this; }
const_iterator & operator+=(difference_type delta)
Increment and decrement operators.
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator< ( const const_iterator than) const
inlineinherited

Iterator comparisons.

Definition at line 1228 of file sparse_vector.h.

References lar::sparse_vector< T >::const_iterator::cont, and lar::sparse_vector< T >::const_iterator::index.

1229  { return (cont == than.cont) && (index < than.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator<= ( const const_iterator than) const
inlineinherited

Iterator comparisons.

Definition at line 1232 of file sparse_vector.h.

References lar::sparse_vector< T >::const_iterator::cont, and lar::sparse_vector< T >::const_iterator::index.

1233  { return (cont == than.cont) && (index <= than.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator== ( const const_iterator as) const
inlineinherited

Iterator comparisons.

Definition at line 1224 of file sparse_vector.h.

1225  { return (cont == as.cont) && (index == as.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator> ( const const_iterator than) const
inlineinherited

Iterator comparisons.

Definition at line 1230 of file sparse_vector.h.

References lar::sparse_vector< T >::const_iterator::cont, and lar::sparse_vector< T >::const_iterator::index.

1231  { return (cont == than.cont) && (index > than.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
bool lar::sparse_vector< T >::const_iterator::operator>= ( const const_iterator than) const
inlineinherited

Iterator comparisons.

Definition at line 1234 of file sparse_vector.h.

References lar::sparse_vector< T >::const_iterator::cont, and lar::sparse_vector< T >::const_iterator::index.

1235  { return (cont == than.cont) && (index >= than.index); }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T>
reference lar::sparse_vector< T >::iterator::operator[] ( size_type  offset) const
inline

Random access.

Definition at line 1318 of file sparse_vector.h.

References shims::map< Key, T, Compare, Allocator >::iter< Category, TT, Distance, Pointer, Reference >::operator++().

1319  { return (*const_iterator::cont)[const_iterator::index + offset]; }
const container_t * cont
pointer to the container
size_type index
pointer to the current value, as absolute index
template<typename T >
void lar::sparse_vector< T >::const_iterator::refresh_state ( )
protectedinherited

Reassigns the internal state according to the index.

Definition at line 1979 of file sparse_vector.h.

1979  {
1980  // update the currentRange
1981  // currentRange is the range including the current item, or next to it
1982  if (cont) {
1983  // the following is actually the range after the index:
1985  // if the index is inside the previous index, then we want to move there:
1986  if (currentRange != cont->ranges.begin()) {
1987  if ((currentRange - 1)->end_index() > index) --currentRange;
1988  }
1989  }
1990  else {
1991  currentRange = {};
1992  }
1993 } // lar::sparse_vector<T>::const_iterator::refresh_state()
const container_t * cont
pointer to the container
ranges_const_iterator currentRange
pointer to the current (or next) range
range_list_t ranges
list of ranges
range_iterator find_next_range_iter(size_type index)
Returns an iterator to the range after index, or end() if none.
size_type index
pointer to the current value, as absolute index

Member Data Documentation

template<typename T>
ranges_const_iterator lar::sparse_vector< T >::const_iterator::currentRange
protectedinherited

pointer to the current (or next) range

Definition at line 1274 of file sparse_vector.h.


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