Classes | Namespaces | Functions
sparse_vector.h File Reference

Class defining a sparse vector (holes are zeroes) More...

#include <cstddef>
#include <stdexcept>
#include <vector>
#include <ostream>
#include <iterator>
#include <algorithm>
#include <numeric>
#include <type_traits>

Go to the source code of this file.

Classes

class  lar::const_value_box< T >
 Little class storing a value. More...
 
class  lar::value_const_iterator< T >
 A constant iterator returning always the same value. More...
 
class  lar::range_t< SIZE >
 A range (interval) of integers. More...
 
class  lar::sparse_vector< T >
 A sparse vector. More...
 
class  lar::sparse_vector< T >
 A sparse vector. More...
 
class  lar::sparse_vector< T >::datarange_t
 Range class, with range and data. More...
 
class  lar::sparse_vector< T >::const_datarange_t
 A constant reference to a data range. More...
 
class  lar::sparse_vector< T >::const_reference
 Special little box to allow void elements to be treated as references. More...
 
class  lar::sparse_vector< T >::reference
 A class representing a cell in a sparse vector. More...
 
class  lar::sparse_vector< T >::const_iterator
 Iterator to the sparse vector values. More...
 
struct  lar::sparse_vector< T >::const_iterator::special
 Namespace for special initialization. More...
 
class  lar::sparse_vector< T >::const_iterator::special::begin
 
class  lar::sparse_vector< T >::const_iterator::special::end
 
class  lar::sparse_vector< T >::iterator
 Iterator to the sparse vector values. More...
 
class  lar::details::iteratorRange< BITER, EITER >
 Enclosure to use two iterators representing a range in a range-for loop. More...
 
class  lar::details::const_datarange_iterator< T >
 

Namespaces

 lar
 LArSoft-specific namespace.
 
 lar::details
 Namespace hiding implementation details.
 

Functions

template<typename T >
value_const_iterator< T > lar::operator+ (typename value_const_iterator< T >::difference_type ofs, value_const_iterator< T > &iter)
 Returns an iterator pointing ahead of this one by the specified steps. More...
 
template<typename T >
decltype(auto) lar::details::make_const_datarange_t (typename sparse_vector< T >::datarange_t &r)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const lar::sparse_vector< T > &v)
 Prints a sparse vector into a stream. More...
 

Detailed Description

Class defining a sparse vector (holes are zeroes)

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
April 22, 2014
Version
1.0

Definition in file sparse_vector.h.

Function Documentation

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
const lar::sparse_vector< T > &  v 
)

Prints a sparse vector into a stream.

Template Parameters
Ttemplate type of the sparse vector
Parameters
outoutput stream
vthe sparse vector to be written
Returns
the output stream (out)

The output is in the form:

Sparse vector of size ## with ## ranges:
  [min1 - max1] (size1) { elements of the first range }
  [min2 - max2] (size2) { elements of the second range }
  ...

Definition at line 2324 of file sparse_vector.h.

2324  {
2325 
2326  out << "Sparse vector of size " << v.size() << " with "
2327  << v.get_ranges().size() << " ranges:";
2329  iRange = v.begin_range(), rend = v.end_range();
2330  while (iRange != rend) {
2331  out << "\n ";
2332  iRange->dump(out);
2333  /*
2334  out << "\n [" << iRange->begin_index() << " - " << iRange->end_index()
2335  << "] (" << iRange->size() << "):";
2336  typename lar::sparse_vector<T>::datarange_t::const_iterator
2337  iValue = iRange->begin(), vend = iRange->end();
2338  while (iValue != vend) out << " " << (*(iValue++));
2339  */
2340  ++iRange;
2341  } // for
2342  return out << std::endl;
2343 } // operator<< (ostream, sparse_vector<T>)
size_type size() const
Returns the size of the vector.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
range_const_iterator begin_range() const
Returns a constant iterator to the first data range.
range_list_t::const_iterator range_const_iterator
type of constant iterator over ranges
range_const_iterator end_range() const
Returns a constant iterator to after the last data range.
QTextStream & endl(QTextStream &s)