ProteoWizard
Public Types | Public Member Functions | List of all members
pwiz::analysis::MZRTField< T > Struct Template Reference

MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT. More...

#include <MZRTField.hpp>

Inheritance diagram for pwiz::analysis::MZRTField< T >:

Public Types

typedef boost::shared_ptr< T > TPtr
 

Public Member Functions

template<typename RTMatches >
std::vector< TPtrfind (double mz, MZTolerance mzTolerance, RTMatches matches) const
 find all objects with a given m/z, within a given m/z tolerance, satisfying the 'matches' predicate More...
 
void remove (const TPtr &p)
 remove an object via a shared reference, rather than an iterator into the set More...
 
template<typename RTMatches >
std::vector< boost::shared_ptr< T > > find (double mz, MZTolerance mzTolerance, RTMatches matches) const
 

Detailed Description

template<typename T>
struct pwiz::analysis::MZRTField< T >

MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT.

Definition at line 94 of file MZRTField.hpp.

Member Typedef Documentation

§ TPtr

template<typename T>
typedef boost::shared_ptr<T> pwiz::analysis::MZRTField< T >::TPtr

Definition at line 98 of file MZRTField.hpp.

Member Function Documentation

§ find() [1/2]

template<typename T>
template<typename RTMatches >
std::vector<TPtr> pwiz::analysis::MZRTField< T >::find ( double  mz,
MZTolerance  mzTolerance,
RTMatches  matches 
) const

find all objects with a given m/z, within a given m/z tolerance, satisfying the 'matches' predicate

Referenced by testFeatureField(), testFind(), testPeakelField(), verifyBombesinFeatures(), and verifyBombesinPeakels().

§ remove()

template<typename T >
void pwiz::analysis::MZRTField< T >::remove ( const TPtr p)

remove an object via a shared reference, rather than an iterator into the set

Definition at line 193 of file MZRTField.hpp.

Referenced by testPeakelField().

194 {
195  std::pair<typename MZRTField<T>::iterator, typename MZRTField<T>::iterator>
196  range = this->equal_range(p); // uses LessThan_MZRT
197 
198  typename MZRTField<T>::iterator
199  found = std::find(range.first, range.second, p); // uses shared_ptr::operator==
200 
201  if (found == range.second) throw std::runtime_error("[MZRTField::remove()] TPtr not found.");
202 
203  this->erase(found);
204 }

§ find() [2/2]

template<typename T>
template<typename RTMatches >
std::vector< boost::shared_ptr<T> > pwiz::analysis::MZRTField< T >::find ( double  mz,
MZTolerance  mzTolerance,
RTMatches  matches 
) const

Definition at line 168 of file MZRTField.hpp.

169 {
170  TPtr target(new T);
171 
172  // use binary search to get a std::set iterator range
173 
174  target->mz = mz - mzTolerance;
175  typename MZRTField<T>::const_iterator begin = this->lower_bound(target);
176 
177  target->mz = mz + mzTolerance;
178  typename MZRTField<T>::const_iterator end = this->upper_bound(target);
179 
180  // linear copy_if within range
181 
182  std::vector<TPtr> result;
183 
184  for (typename MZRTField<T>::const_iterator it=begin; it!=end; ++it)
185  if (matches(**it))
186  result.push_back(*it);
187 
188  return result;
189 }
boost::shared_ptr< T > TPtr
Definition: MZRTField.hpp:98
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
Definition: Ion.hpp:78

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