ProteoWizard
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ralab::base::resample::Bucket1D Struct Reference

#include <bucket1d.hpp>

Public Member Functions

 Bucket1D (std::vector< double > &breaks, std::vector< uint32_t > &indic)
 CTor. More...
 
 Bucket1D (const Bucket1D &rhs)
 CCTor. More...
 
Bucket1Doperator= (const Bucket1D &rhs)
 
template<typename InputIterator >
void operator() (InputIterator beg, InputIterator end, std::vector< std::pair< std::size_t, std::size_t > > &bucketPairs)
 The result tells you in which bucket which input should end up. More...
 
std::pair< std::size_t, bool > operator() (double dat)
 the std::size_t indicates to which bucket dat belongs too. The bool indicates if a new bucket is of interest More...
 

Private Member Functions

void set (const std::vector< double > &breaks, const std::vector< uint32_t > &indic)
 set the data More...
 

Private Attributes

std::vector< double > breaks_
 
std::vector< uint32_tindicator_
 
double * begbreaks_
 
double * endbreaks_
 
uint32_tindicatorptr_
 

Detailed Description

Definition at line 38 of file bucket1d.hpp.

Constructor & Destructor Documentation

§ Bucket1D() [1/2]

ralab::base::resample::Bucket1D::Bucket1D ( std::vector< double > &  breaks,
std::vector< uint32_t > &  indic 
)
inline

CTor.

Definition at line 50 of file bucket1d.hpp.

References ralab::base::resample::breaks().

54  {
55  set( breaks , indic );
56  }
std::vector< uint32_t > indicator_
Definition: bucket1d.hpp:42
std::vector< double > breaks_
Definition: bucket1d.hpp:41
void breaks(double minMass, double maxMass, TMassComparator tmassComp, std::vector< double > &breaks, bool exact=false)
Segment mass range according to Mass Compare functor could be used to histogram a dataset or to compu...
Definition: breakspec.hpp:41

§ Bucket1D() [2/2]

ralab::base::resample::Bucket1D::Bucket1D ( const Bucket1D rhs)
inline

CCTor.

Definition at line 59 of file bucket1d.hpp.

References breaks_, and indicator_.

62  {
63  this->set(rhs.breaks_,rhs.indicator_);
64  }
std::vector< uint32_t > indicator_
Definition: bucket1d.hpp:42
std::vector< double > breaks_
Definition: bucket1d.hpp:41

Member Function Documentation

§ set()

void ralab::base::resample::Bucket1D::set ( const std::vector< double > &  breaks,
const std::vector< uint32_t > &  indic 
)
inlineprivate

set the data

Definition at line 68 of file bucket1d.hpp.

References ralab::base::resample::breaks().

70  {
71  if(( breaks.size() - 1 ) != indic.size()){
72  throw std::out_of_range( "breaks.size == inic + 1 , failed!" );
73  }
74  breaks_ = breaks;
75  begbreaks_ = &breaks_[0];
76  endbreaks_ = begbreaks_ + breaks_.size();
77  indicator_ = indic;
79  }
std::vector< uint32_t > indicator_
Definition: bucket1d.hpp:42
std::vector< double > breaks_
Definition: bucket1d.hpp:41
void breaks(double minMass, double maxMass, TMassComparator tmassComp, std::vector< double > &breaks, bool exact=false)
Segment mass range according to Mass Compare functor could be used to histogram a dataset or to compu...
Definition: breakspec.hpp:41

§ operator=()

Bucket1D& ralab::base::resample::Bucket1D::operator= ( const Bucket1D rhs)
inline

Definition at line 84 of file bucket1d.hpp.

References breaks_, and indicator_.

85  {
86  if (this == &rhs) // protect against invalid self-assignment
87  return *this; // See "4:"
88  this->set( rhs.breaks_, rhs.indicator_);
89  return *this;
90  }

§ operator()() [1/2]

template<typename InputIterator >
void ralab::base::resample::Bucket1D::operator() ( InputIterator  beg,
InputIterator  end,
std::vector< std::pair< std::size_t, std::size_t > > &  bucketPairs 
)
inline

The result tells you in which bucket which input should end up.

Parameters
begCheck wich of these masses should be bucketed

Definition at line 96 of file bucket1d.hpp.

101  {
102  std::size_t index(0);
103  std::pair<std::size_t, bool> res;
104  for(;beg !=end; ++beg, ++index)
105  {
106  res = this->operator()(*beg);
107  if(res.second)
108  {
109  bucketPairs.push_back(std::make_pair(res.first , index ));
110  }
111  }
112  }
void operator()(InputIterator beg, InputIterator end, std::vector< std::pair< std::size_t, std::size_t > > &bucketPairs)
The result tells you in which bucket which input should end up.
Definition: bucket1d.hpp:96

§ operator()() [2/2]

std::pair<std::size_t, bool> ralab::base::resample::Bucket1D::operator() ( double  dat)
inline

the std::size_t indicates to which bucket dat belongs too. The bool indicates if a new bucket is of interest

Definition at line 119 of file bucket1d.hpp.

120  {
121  double * it2 = std::lower_bound(begbreaks_,endbreaks_,dat);
122  std::size_t ub = std::distance(begbreaks_,it2);
123 
124  if(ub > 0 && ub <= indicator_.size())
125  {
126  ub = ub - 1;
127  if(*(indicatorptr_ + ub) > 0)
128  return std::make_pair(ub, true);
129  else
130  return std::make_pair(ub, false);
131  }
132  else
133  return std::make_pair(0, false);
134  }
std::vector< uint32_t > indicator_
Definition: bucket1d.hpp:42

Member Data Documentation

§ breaks_

std::vector<double> ralab::base::resample::Bucket1D::breaks_
private

Definition at line 41 of file bucket1d.hpp.

Referenced by Bucket1D(), and operator=().

§ indicator_

std::vector<uint32_t> ralab::base::resample::Bucket1D::indicator_
private

Definition at line 42 of file bucket1d.hpp.

Referenced by Bucket1D(), and operator=().

§ begbreaks_

double* ralab::base::resample::Bucket1D::begbreaks_
private

Definition at line 45 of file bucket1d.hpp.

§ endbreaks_

double* ralab::base::resample::Bucket1D::endbreaks_
private

Definition at line 46 of file bucket1d.hpp.

§ indicatorptr_

uint32_t* ralab::base::resample::Bucket1D::indicatorptr_
private

Definition at line 47 of file bucket1d.hpp.


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