void MSSpectrum::sortByIntensity(bool reverse) { if (float_data_arrays_.empty() && string_data_arrays_.empty() && integer_data_arrays_.empty()) { if (reverse) { std::stable_sort(ContainerType::begin(), ContainerType::end(), reverseComparator(PeakType::IntensityLess())); } else { std::stable_sort(ContainerType::begin(), ContainerType::end(), PeakType::IntensityLess()); } } else { // sort index list std::vector<std::pair<PeakType::IntensityType, Size> > sorted_indices; sorted_indices.reserve(ContainerType::size()); for (Size i = 0; i < ContainerType::size(); ++i) { sorted_indices.push_back(std::make_pair(ContainerType::operator[](i).getIntensity(), i)); } if (reverse) { std::stable_sort(sorted_indices.begin(), sorted_indices.end(), reverseComparator(PairComparatorFirstElement<std::pair<PeakType::IntensityType, Size> >())); } else { std::stable_sort(sorted_indices.begin(), sorted_indices.end(), PairComparatorFirstElement<std::pair<PeakType::IntensityType, Size> >()); } // extract list of indices std::vector<Size> select_indices; select_indices.reserve(sorted_indices.size()); for (Size i = 0; i < sorted_indices.size(); ++i) { select_indices.push_back(sorted_indices[i].second); } select(select_indices); } }
void ConsensusMap::sortByQuality(bool reverse) { if (reverse) { std::stable_sort(Base::begin(), Base::end(), reverseComparator(ConsensusFeature::QualityLess())); } else { std::stable_sort(Base::begin(), Base::end(), ConsensusFeature::QualityLess()); } }
void FeatureMap::sortByOverallQuality(bool reverse) { if (reverse) { std::sort(this->begin(), this->end(), reverseComparator(FeatureType::OverallQualityLess())); } else { std::sort(this->begin(), this->end(), FeatureType::OverallQualityLess()); } }
void ConsensusMap::sortBySize() { std::stable_sort(Base::begin(), Base::end(), reverseComparator(ConsensusFeature::SizeLess())); }