16 #include <type_traits>
44 template <
typename CONT_T,
typename TRAIT,
bool CONST_T = true >
52 using pointer =
typename std::conditional<CONST_T, typename CONT_T::value_type const*, typename CONT_T::value_type*>::type;
53 using reference =
typename std::conditional<CONST_T, typename CONT_T::value_type const&, typename CONT_T::value_type&>::type;
55 using CONT_IT =
typename std::conditional<CONST_T, typename CONT_T::const_iterator, typename CONT_T::iterator>::type;
112 if (
this == &rhs)
return true;
128 return !(*
this == rhs);
132 template<
bool _CONST = CONST_T >
133 typename std::enable_if< _CONST, reference >::type
operator*()
const
137 template<
bool _CONST = CONST_T >
138 typename std::enable_if< !_CONST, reference >::type
operator*()
144 template<
bool _CONST = CONST_T >
145 typename std::enable_if< _CONST, pointer >::type
operator->()
const
149 template<
bool _CONST = CONST_T >
150 typename std::enable_if< !_CONST, pointer >::type
operator->()
225 double max_dist = TRAIT::allowedTol(
tol_, *
it_ref_);
228 float diff = std::numeric_limits<float>::max();
248 if (diff <= max_dist)
return;
268 template <
typename T>
274 template <
typename T>
277 return fabs(elem_ref - elem_tgt);
285 template <
typename T>
291 template <
typename T>
294 return fabs(elem_ref.getMZ() - elem_tgt.getMZ());
302 template <
typename T>
308 template <
typename T>
311 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:46
CONT_IT it_ref_
Definition: MatchedIterator.h:260
bool operator!=(const MatchedIterator &rhs) const
Definition: MatchedIterator.h:126
CONST_CONT_IT ref_end_
Definition: MatchedIterator.h:258
MatchedIterator & operator++()
Advances to the next valid pair.
Definition: MatchedIterator.h:178
MatchedIterator(const MatchedIterator &rhs)=default
Copy CTor (default)
CONST_CONT_IT tgt_end_
Definition: MatchedIterator.h:259
typename std::conditional< CONST_T, typename CONT_T::value_type const &, typename CONT_T::value_type & >::type reference
Definition: MatchedIterator.h:53
CONT_IT it_tgt_
Definition: MatchedIterator.h:260
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:83
MatchedIterator & operator=(const MatchedIterator &rhs)=default
Assignment operator (default)
MatchedIterator(bool)
Definition: MatchedIterator.h:205
size_t refIdx() const
index into reference container
Definition: MatchedIterator.h:162
bool isEnd_() const
Definition: MatchedIterator.h:215
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:67
std::forward_iterator_tag iterator_category
Definition: MatchedIterator.h:49
typename CONT_T::const_iterator CONST_CONT_IT
Definition: MatchedIterator.h:56
void advanceTarget_()
Definition: MatchedIterator.h:220
bool operator==(const MatchedIterator &rhs) const
Definition: MatchedIterator.h:110
size_t tgtIdx() const
index into target container
Definition: MatchedIterator.h:168
MatchedIterator operator++(int)
post-increment
Definition: MatchedIterator.h:188
bool is_end_
Definition: MatchedIterator.h:262
typename CONT_T::value_type value_type
Definition: MatchedIterator.h:50
std::enable_if< _CONST, reference >::type operator*() const
dereference current target element
Definition: MatchedIterator.h:133
typename std::conditional< CONST_T, typename CONT_T::value_type const *, typename CONT_T::value_type * >::type pointer
Definition: MatchedIterator.h:52
static MatchedIterator end()
the end iterator
Definition: MatchedIterator.h:196
CONST_CONT_IT tgt_begin_
Definition: MatchedIterator.h:259
const value_type & ref() const
current element in reference container
Definition: MatchedIterator.h:156
std::enable_if< _CONST, pointer >::type operator->() const
pointer to current target element
Definition: MatchedIterator.h:145
std::enable_if< !_CONST, reference >::type operator*()
Definition: MatchedIterator.h:138
std::ptrdiff_t difference_type
Definition: MatchedIterator.h:51
MatchedIterator()
Default CTor; do not use this for anything other than assigning to it;.
Definition: MatchedIterator.h:99
CONST_CONT_IT ref_begin_
Definition: MatchedIterator.h:258
void setToEnd_()
Definition: MatchedIterator.h:210
float tol_
Definition: MatchedIterator.h:261
std::enable_if< !_CONST, pointer >::type operator->()
Definition: MatchedIterator.h:150
typename std::conditional< CONST_T, typename CONT_T::const_iterator, typename CONT_T::iterator >::type CONT_IT
Definition: MatchedIterator.h:55
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:94
T ppmToMass(T ppm, T mz_ref)
Compute the mass diff in [Th], given a ppm value and a reference point.
Definition: MathFunctions.h:309
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Definition: MatchedIterator.h:301
static float getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
for Peak1D & Co
Definition: MatchedIterator.h:309
static float allowedTol(float tol, const T &)
Definition: MatchedIterator.h:303
Definition: MatchedIterator.h:284
static float getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
for Peak1D & Co
Definition: MatchedIterator.h:292
static float allowedTol(float tol, const T &elem_ref)
Definition: MatchedIterator.h:286
Trait for MatchedIterator to find pairs with a certain distance, which is computed directly on the va...
Definition: MatchedIterator.h:267
static T getDiffAbsolute(const T &elem_ref, const T &elem_tgt)
just use fabs on the value directly
Definition: MatchedIterator.h:275
static float allowedTol(float tol, const T &)
Definition: MatchedIterator.h:269