42 #include <type_traits>
70 template <
typename CONT_T,
typename TRAIT,
bool CONST_T = true >
78 using pointer =
typename std::conditional<CONST_T, typename CONT_T::value_type const*, typename CONT_T::value_type*>::type;
79 using reference =
typename std::conditional<CONST_T, typename CONT_T::value_type const&, typename CONT_T::value_type&>::type;
81 using CONT_IT =
typename std::conditional<CONST_T, typename CONT_T::const_iterator, typename CONT_T::iterator>::type;
138 if (
this == &rhs)
return true;
154 return !(*
this == rhs);
158 template<
bool _CONST = CONST_T >
159 typename std::enable_if< _CONST, reference >::type
operator*()
const
163 template<
bool _CONST = CONST_T >
164 typename std::enable_if< !_CONST, reference >::type
operator*()
170 template<
bool _CONST = CONST_T >
171 typename std::enable_if< _CONST, pointer >::type
operator->()
const
175 template<
bool _CONST = CONST_T >
176 typename std::enable_if< !_CONST, pointer >::type
operator->()
251 double max_dist = TRAIT::allowedTol(
tol_, *
it_ref_);
254 float diff = std::numeric_limits<float>::max();
274 if (diff <= max_dist)
return;
294 template <
typename T>
300 template <
typename T>
303 return fabs(elem_ref - elem_tgt);
311 template <
typename T>
317 template <
typename T>
320 return fabs(elem_ref.getMZ() - elem_tgt.getMZ());
328 template <
typename T>
334 template <
typename T>
337 return fabs(elem_ref.getMZ() - elem_tgt.getMZ());
For each element in the reference container the closest peak in the target will be searched....
Definition: MatchedIterator.h:72
CONT_IT it_ref_
Definition: MatchedIterator.h:286
bool operator!=(const MatchedIterator &rhs) const
Definition: MatchedIterator.h:152
CONST_CONT_IT ref_end_
Definition: MatchedIterator.h:284
MatchedIterator & operator++()
Advances to the next valid pair.
Definition: MatchedIterator.h:204
MatchedIterator(const MatchedIterator &rhs)=default
Copy CTor (default)
CONST_CONT_IT tgt_end_
Definition: MatchedIterator.h:285
typename std::conditional< CONST_T, typename CONT_T::value_type const &, typename CONT_T::value_type & >::type reference
Definition: MatchedIterator.h:79
CONT_IT it_tgt_
Definition: MatchedIterator.h:286
MatchedIterator(const CONST_CONT_IT ref_begin, const CONST_CONT_IT ref_end, const CONST_CONT_IT tgt_begin, const CONST_CONT_IT tgt_end, float tolerance)
Constructs a MatchedIterator on two containers. The way a match is found, depends on the TRAIT type (...
Definition: MatchedIterator.h:109
MatchedIterator & operator=(const MatchedIterator &rhs)=default
Assignment operator (default)
MatchedIterator(bool)
Definition: MatchedIterator.h:231
size_t refIdx() const
index into reference container
Definition: MatchedIterator.h:188
bool isEnd_() const
Definition: MatchedIterator.h:241
MatchedIterator(const CONT_T &ref, const CONT_T &target, float tolerance)
Constructs a MatchedIterator on two containers. The way a match is found, depends on the TRAIT type (...
Definition: MatchedIterator.h:93
std::forward_iterator_tag iterator_category
Definition: MatchedIterator.h:75
typename CONT_T::const_iterator CONST_CONT_IT
Definition: MatchedIterator.h:82
void advanceTarget_()
Definition: MatchedIterator.h:246
bool operator==(const MatchedIterator &rhs) const
Definition: MatchedIterator.h:136
size_t tgtIdx() const
index into target container
Definition: MatchedIterator.h:194
MatchedIterator operator++(int)
post-increment
Definition: MatchedIterator.h:214
bool is_end_
Definition: MatchedIterator.h:288
typename CONT_T::value_type value_type
Definition: MatchedIterator.h:76
std::enable_if< _CONST, reference >::type operator*() const
dereference current target element
Definition: MatchedIterator.h:159
typename std::conditional< CONST_T, typename CONT_T::value_type const *, typename CONT_T::value_type * >::type pointer
Definition: MatchedIterator.h:78
static MatchedIterator end()
the end iterator
Definition: MatchedIterator.h:222
CONST_CONT_IT tgt_begin_
Definition: MatchedIterator.h:285
const value_type & ref() const
current element in reference container
Definition: MatchedIterator.h:182
std::enable_if< _CONST, pointer >::type operator->() const
pointer to current target element
Definition: MatchedIterator.h:171
std::enable_if< !_CONST, reference >::type operator*()
Definition: MatchedIterator.h:164
std::ptrdiff_t difference_type
Definition: MatchedIterator.h:77
MatchedIterator()
Default CTor; do not use this for anything other than assigning to it;.
Definition: MatchedIterator.h:125
CONST_CONT_IT ref_begin_
Definition: MatchedIterator.h:284
void setToEnd_()
Definition: MatchedIterator.h:236
float tol_
Definition: MatchedIterator.h:287
std::enable_if< !_CONST, pointer >::type operator->()
Definition: MatchedIterator.h:176
typename std::conditional< CONST_T, typename CONT_T::const_iterator, typename CONT_T::iterator >::type CONT_IT
Definition: MatchedIterator.h:81
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:120
T ppmToMass(T ppm, T mz_ref)
Compute the mass diff in [Th], given a ppm value and a reference point.
Definition: MathFunctions.h:335
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
Definition: MatchedIterator.h:327
static float getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
for Peak1D & Co
Definition: MatchedIterator.h:335
static float allowedTol(float tol, const T &)
Definition: MatchedIterator.h:329
Definition: MatchedIterator.h:310
static float getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
for Peak1D & Co
Definition: MatchedIterator.h:318
static float allowedTol(float tol, const T &elem_ref)
Definition: MatchedIterator.h:312
Trait for MatchedIterator to find pairs with a certain distance, which is computed directly on the va...
Definition: MatchedIterator.h:293
static T getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
just use fabs on the value directly
Definition: MatchedIterator.h:301
static float allowedTol(float tol, const T &)
Definition: MatchedIterator.h:295