Fix/autoptr
... | ... |
@@ -1,3 +1,8 @@ |
1 |
+2023-02-12 Steffen Neumann <sneumann@msbi-corei> |
|
2 |
+ |
|
3 |
+ * search&replace deprecated auto_ptr with unique_ptr |
|
4 |
+ * use labda functions instead of e.g. bind2nd() |
|
5 |
+ |
|
1 | 6 |
2019-05-02 Steffen Neumann <sneumann@msbi-corei> |
2 | 7 |
|
3 | 8 |
* Rdisop-1.45.1: Merge fix by Max Helf for improved |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Package: Rdisop |
2 | 2 |
Title: Decomposition of Isotopic Patterns |
3 |
-Version: 1.45.1 |
|
4 |
-Date: 2019-05-02 |
|
3 |
+Version: 1.59.1 |
|
4 |
+Date: 2023-02-12 |
|
5 | 5 |
Author: Anton Pervukhin <apervukh@minet.uni-jena.de>, Steffen Neumann <sneumann@ipb-halle.de> |
6 | 6 |
Maintainer: Steffen Neumann <sneumann@ipb-halle.de> |
7 | 7 |
Description: Identification of metabolites using high precision mass |
... | ... |
@@ -322,7 +322,7 @@ RcppExport SEXP decomposeIsotopes(SEXP v_masses, SEXP v_abundances, SEXP s_error |
322 | 322 |
transform(candidate_abundances.begin(), // begin of source range |
323 | 323 |
candidate_abundances.begin() + size, // end of source range |
324 | 324 |
candidate_abundances.begin(), // destination |
325 |
- bind2nd(multiplies<abundance_type>(), scale)); // operation (*scale) |
|
325 |
+ [scale](abundance_type a) { return a * scale; }); // operation (*scale) |
|
326 | 326 |
} |
327 | 327 |
|
328 | 328 |
} |
... | ... |
@@ -29,9 +29,9 @@ Alphabet::mass_type Alphabet::getMass(const name_type& name) const |
29 | 29 |
|
30 | 30 |
|
31 | 31 |
bool Alphabet::hasName(const name_type& name) const { |
32 |
- return std::find_if(elements.begin(), elements.end(), |
|
33 |
- compose_f_gx(std::bind2nd(std::equal_to<name_type>(), name), |
|
34 |
- std::mem_fun_ref(&element_type::getName))) < elements.end(); |
|
32 |
+ return std::find_if(elements.begin(), elements.end(), [name](const auto& elem) { |
|
33 |
+ return std::equal_to<name_type>()(elem.getName(), name); |
|
34 |
+ }) != elements.end(); |
|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
|
... | ... |
@@ -68,11 +68,9 @@ Alphabet::masses_type Alphabet::getAverageMasses() const { |
68 | 68 |
|
69 | 69 |
|
70 | 70 |
void Alphabet::sortByNames() { |
71 |
- std::sort(elements.begin(), elements.end(), |
|
72 |
- compose_f_gx_hy( |
|
73 |
- std::less<name_type>(), |
|
74 |
- std::mem_fun_ref(&element_type::getName), |
|
75 |
- std::mem_fun_ref(&element_type::getName))); |
|
71 |
+ std::sort(elements.begin(), elements.end(), [](const auto& lhs, const auto& rhs) { |
|
72 |
+ return std::less<name_type>()(lhs.getName(), rhs.getName()); |
|
73 |
+ }); |
|
76 | 74 |
} |
77 | 75 |
|
78 | 76 |
|
... | ... |
@@ -54,7 +54,7 @@ class Calibrator { |
54 | 54 |
/** Returns the actual mapping computed by the last call to match(). |
55 | 55 |
* @b Only usable for one-to-one mappings. |
56 | 56 |
*/ |
57 |
- virtual std::auto_ptr<std::map<int,int> > getMapping() const = 0; |
|
57 |
+ virtual std::unique_ptr<std::map<int,int> > getMapping() const = 0; |
|
58 | 58 |
|
59 | 59 |
virtual LinearTransformation getTransformation() const = 0; |
60 | 60 |
|
... | ... |
@@ -102,7 +102,7 @@ void Calibrator<ListA,ListB>::reducedLists( |
102 | 102 |
ListB& b_reduced) const |
103 | 103 |
{ |
104 | 104 |
// TODO: use exceptions here |
105 |
- std::auto_ptr<std::map<int,int> > mapping_ptr = getMapping(); |
|
105 |
+ std::unique_ptr<std::map<int,int> > mapping_ptr = getMapping(); |
|
106 | 106 |
assert(mapping_ptr.get() != NULL); |
107 | 107 |
std::map<int,int> &mapping = *mapping_ptr; // TODO |
108 | 108 |
a_reduced.clear(); |
... | ... |
@@ -135,7 +135,7 @@ ListB Calibrator<ListA,ListB>::recalibrated(const ListA& predicted, const ListB& |
135 | 135 |
ListB measured_reduced; |
136 | 136 |
reducedLists(predicted, measured, predicted_reduced, measured_reduced); |
137 | 137 |
ChebyshevFitter fitter(degree); |
138 |
- std::auto_ptr<PolynomialTransformation> transformation = fitter.fit( |
|
138 |
+ std::unique_ptr<PolynomialTransformation> transformation = fitter.fit( |
|
139 | 139 |
predicted_reduced.template begin<typename ListA::peak_type::MassGetter>(), |
140 | 140 |
predicted_reduced.template end<typename ListA::peak_type::MassGetter>(), |
141 | 141 |
measured_reduced.template begin<typename ListB::peak_type::MassGetter>(), |
... | ... |
@@ -47,7 +47,7 @@ class GeometricCalibrator : public Calibrator<ListA,ListB> { |
47 | 47 |
min_pointpaircount = std::max((size_t)2, count); |
48 | 48 |
} |
49 | 49 |
|
50 |
- virtual std::auto_ptr<std::map<int,int> > getMapping() const; |
|
50 |
+ virtual std::unique_ptr<std::map<int,int> > getMapping() const; |
|
51 | 51 |
|
52 | 52 |
virtual LinearTransformation getTransformation() const; |
53 | 53 |
|
... | ... |
@@ -63,7 +63,7 @@ class GeometricCalibrator : public Calibrator<ListA,ListB> { |
63 | 63 |
|
64 | 64 |
private: |
65 | 65 |
void convertToPoints(const ListA& a, const ListB& b); |
66 |
- std::auto_ptr<std::map<int,int> > realMatch(const ListA& a, const ListB& b, const LinearTransformation& t, double epsilon, bool restricted); // TODO parameters |
|
66 |
+ std::unique_ptr<std::map<int,int> > realMatch(const ListA& a, const ListB& b, const LinearTransformation& t, double epsilon, bool restricted); // TODO parameters |
|
67 | 67 |
|
68 | 68 |
double epsilon; |
69 | 69 |
double abslimit; |
... | ... |
@@ -74,7 +74,7 @@ class GeometricCalibrator : public Calibrator<ListA,ListB> { |
74 | 74 |
size_t min_pointpaircount; |
75 | 75 |
bool have_mapping; |
76 | 76 |
bool have_transformation; |
77 |
- std::auto_ptr<std::map<int,int> > mapping; |
|
77 |
+ std::unique_ptr<std::map<int,int> > mapping; |
|
78 | 78 |
LinearTransformation transformation; |
79 | 79 |
}; |
80 | 80 |
|
... | ... |
@@ -96,7 +96,7 @@ GeometricCalibrator<ListA,ListB>::GeometricCalibrator(double epsilon) : |
96 | 96 |
|
97 | 97 |
|
98 | 98 |
template <typename ListA, typename ListB> |
99 |
-std::auto_ptr<std::map<int,int> > GeometricCalibrator<ListA,ListB>::realMatch(const ListA& a, const ListB& b, const LinearTransformation& t, double epsilon, bool restricted) |
|
99 |
+std::unique_ptr<std::map<int,int> > GeometricCalibrator<ListA,ListB>::realMatch(const ListA& a, const ListB& b, const LinearTransformation& t, double epsilon, bool restricted) |
|
100 | 100 |
{ |
101 | 101 |
// TODO: one could optimize (similar to calc_pointlist above) |
102 | 102 |
const double accuracy = 0.0001; |
... | ... |
@@ -176,9 +176,9 @@ int GeometricCalibrator<ListA,ListB>::match(const ListA& a, const ListB& b) |
176 | 176 |
|
177 | 177 |
// TODO a bit ugly |
178 | 178 |
template <typename ListA, typename ListB> |
179 |
-std::auto_ptr<std::map<int,int> > GeometricCalibrator<ListA,ListB>::getMapping() const { |
|
179 |
+std::unique_ptr<std::map<int,int> > GeometricCalibrator<ListA,ListB>::getMapping() const { |
|
180 | 180 |
assert(have_mapping); |
181 |
- return std::auto_ptr<std::map<int,int> >(new std::map<int,int>(*mapping)); |
|
181 |
+ return std::unique_ptr<std::map<int,int> >(new std::map<int,int>(*mapping)); |
|
182 | 182 |
} |
183 | 183 |
|
184 | 184 |
template <typename ListA, typename ListB> |
... | ... |
@@ -81,12 +81,12 @@ void LinearPointSetMatcher::swap(double& d1, double& d2) { |
81 | 81 |
d2=h; |
82 | 82 |
} |
83 | 83 |
|
84 |
-std::auto_ptr<std::map<int,int> > LinearPointSetMatcher::getMapping() const { |
|
84 |
+std::unique_ptr<std::map<int,int> > LinearPointSetMatcher::getMapping() const { |
|
85 | 85 |
if (results.mapping.get() == 0) { |
86 |
- return std::auto_ptr<std::map<int,int> >(0); // TODO throw sth. instead |
|
86 |
+ return std::unique_ptr<std::map<int,int> >(new std::map<int,int>()); // TODO throw sth. instead |
|
87 | 87 |
} else { |
88 | 88 |
// aaargh, this syntax is awful, i hate it, hate it, hate it... |
89 |
- return std::auto_ptr<std::map<int,int> >(new std::map<int,int>(*(results.mapping))); |
|
89 |
+ return std::unique_ptr<std::map<int,int> >(new std::map<int,int>(*(results.mapping))); |
|
90 | 90 |
} |
91 | 91 |
} |
92 | 92 |
|
... | ... |
@@ -143,7 +143,7 @@ public: |
143 | 143 |
*/ |
144 | 144 |
// TODO: do we need something like this for the many2one case? |
145 | 145 |
// TODO: int,int -> size_t,size_t |
146 |
- std::auto_ptr<std::map<int,int> > getMapping() const; |
|
146 |
+ std::unique_ptr<std::map<int,int> > getMapping() const; |
|
147 | 147 |
|
148 | 148 |
/** Returns the transformation previously computed by match(). |
149 | 149 |
* Apply this transformation to A to map it to B. |
... | ... |
@@ -166,7 +166,7 @@ protected: |
166 | 166 |
struct { |
167 | 167 |
int bestscore, centerA, centerB; |
168 | 168 |
double bestscale,besttranslation; |
169 |
- std::auto_ptr<std::map<int,int> > mapping; |
|
169 |
+ std::unique_ptr<std::map<int,int> > mapping; |
|
170 | 170 |
} results; |
171 | 171 |
|
172 | 172 |
|
... | ... |
@@ -278,7 +278,7 @@ void LinearPointSetMatcher::countMatchesOneToOne( |
278 | 278 |
#endif |
279 | 279 |
} |
280 | 280 |
|
281 |
- std::auto_ptr<std::map<int,int> > mapping(0); |
|
281 |
+ std::unique_ptr<std::map<int,int> > mapping(new std::map<int,int>()); |
|
282 | 282 |
// evaluate match matrix: count out score using... |
283 | 283 |
if (!restrict_oneToOne) { |
284 | 284 |
// ... greedy counting scheme |
... | ... |
@@ -300,7 +300,7 @@ void LinearPointSetMatcher::countMatchesOneToOne( |
300 | 300 |
results.centerB = j; |
301 | 301 |
results.bestscale = (*p).scale; |
302 | 302 |
results.besttranslation=-results.bestscale*a_first[i] + b_first[j] + diff; |
303 |
- results.mapping=mapping; |
|
303 |
+ results.mapping=std::move(mapping); |
|
304 | 304 |
} |
305 | 305 |
} |
306 | 306 |
} |
... | ... |
@@ -321,9 +321,9 @@ int LinearPointSetMatcher::match(RandomAccessIterator a_first, RandomAccessItera |
321 | 321 |
results.bestscale = 0.0; |
322 | 322 |
results.besttranslation = 0.0; |
323 | 323 |
if (oneToOne) { |
324 |
- results.mapping = std::auto_ptr<std::map<int,int> >(new std::map<int,int>); |
|
324 |
+ results.mapping = std::unique_ptr<std::map<int,int> >(new std::map<int,int>); |
|
325 | 325 |
} else { |
326 |
- results.mapping = std::auto_ptr<std::map<int,int> >(0); |
|
326 |
+ results.mapping = std::unique_ptr<std::map<int,int> >(new std::map<int,int>()); |
|
327 | 327 |
} |
328 | 328 |
|
329 | 329 |
#ifndef NDEBUG |
... | ... |
@@ -78,8 +78,8 @@ size_t MatchMatrix::getRows() { |
78 | 78 |
return rows; |
79 | 79 |
} |
80 | 80 |
|
81 |
-std::auto_ptr<std::map<int,int> > MatchMatrix::countMatches() { |
|
82 |
- std::auto_ptr<std::map<int,int> > m(new std::map<int,int>); |
|
81 |
+std::unique_ptr<std::map<int,int> > MatchMatrix::countMatches() { |
|
82 |
+ std::unique_ptr<std::map<int,int> > m(new std::map<int,int>); |
|
83 | 83 |
int last_match=-1; |
84 | 84 |
int score = 0; |
85 | 85 |
// iterate over rows |
... | ... |
@@ -99,8 +99,8 @@ std::auto_ptr<std::map<int,int> > MatchMatrix::countMatches() { |
99 | 99 |
return m; |
100 | 100 |
} |
101 | 101 |
|
102 |
-std::auto_ptr<std::map<int,int> > MatchMatrix::countMatchesRestrictive() { |
|
103 |
- std::auto_ptr<std::map<int,int> > m(new std::map<int,int>); |
|
102 |
+std::unique_ptr<std::map<int,int> > MatchMatrix::countMatchesRestrictive() { |
|
103 |
+ std::unique_ptr<std::map<int,int> > m(new std::map<int,int>); |
|
104 | 104 |
|
105 | 105 |
int last_match=-1; |
106 | 106 |
int score = 0; |
... | ... |
@@ -58,11 +58,11 @@ public: |
58 | 58 |
std::size_t getRows(); |
59 | 59 |
|
60 | 60 |
/** Greedily compute one-to-one matches. */ |
61 |
- std::auto_ptr<std::map<int,int> > countMatches(); |
|
61 |
+ std::unique_ptr<std::map<int,int> > countMatches(); |
|
62 | 62 |
/** Similar to countMatches() with the restriction, to allow only real one2one matches |
63 | 63 |
* (i.e. matches that are non-ambiguous). |
64 | 64 |
*/ |
65 |
- std::auto_ptr<std::map<int,int> > countMatchesRestrictive(); |
|
65 |
+ std::unique_ptr<std::map<int,int> > countMatchesRestrictive(); |
|
66 | 66 |
}; |
67 | 67 |
|
68 | 68 |
} |
... | ... |
@@ -22,7 +22,7 @@ class PointSetMatcherCalibrator : public Calibrator<ListA,ListB> { |
22 | 22 |
virtual void setMinPointPairCount(size_t count); |
23 | 23 |
virtual bool inputValid(const ListA& a, const ListB& b) const; |
24 | 24 |
virtual int match(const ListA& a, const ListB& b); |
25 |
- virtual std::auto_ptr<std::map<int,int> > getMapping() const; |
|
25 |
+ virtual std::unique_ptr<std::map<int,int> > getMapping() const; |
|
26 | 26 |
virtual LinearTransformation getTransformation() const; |
27 | 27 |
private: |
28 | 28 |
Logger& logger; |
... | ... |
@@ -133,7 +133,7 @@ int PointSetMatcherCalibrator<ListA,ListB>::match(const ListA& a, const ListB& b |
133 | 133 |
|
134 | 134 |
|
135 | 135 |
template <typename ListA, typename ListB> |
136 |
-std::auto_ptr<std::map<int,int> > PointSetMatcherCalibrator<ListA,ListB>::getMapping() const { |
|
136 |
+std::unique_ptr<std::map<int,int> > PointSetMatcherCalibrator<ListA,ListB>::getMapping() const { |
|
137 | 137 |
return lpsm.getMapping(); |
138 | 138 |
} |
139 | 139 |
|
... | ... |
@@ -18,7 +18,7 @@ class ChebyshevFitter { |
18 | 18 |
double getMaximumError() const; |
19 | 19 |
|
20 | 20 |
template <typename RandomAccessIteratorA, typename RandomAccessIteratorB> |
21 |
- std::auto_ptr<PolynomialTransformation> fit( |
|
21 |
+ std::unique_ptr<PolynomialTransformation> fit( |
|
22 | 22 |
RandomAccessIteratorA x, |
23 | 23 |
RandomAccessIteratorA x_end, |
24 | 24 |
RandomAccessIteratorB y, |
... | ... |
@@ -56,7 +56,7 @@ inline double ChebyshevFitter::getMaximumError() const { |
56 | 56 |
* Size of x and y must be > order+1. |
57 | 57 |
*/ |
58 | 58 |
template <typename RandomAccessIteratorA, typename RandomAccessIteratorB> |
59 |
-std::auto_ptr<PolynomialTransformation> ChebyshevFitter::fit( |
|
59 |
+std::unique_ptr<PolynomialTransformation> ChebyshevFitter::fit( |
|
60 | 60 |
const RandomAccessIteratorA x, |
61 | 61 |
const RandomAccessIteratorA x_end, |
62 | 62 |
const RandomAccessIteratorB y, |
... | ... |
@@ -206,7 +206,7 @@ std::auto_ptr<PolynomialTransformation> ChebyshevFitter::fit( |
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
// Copy estimated coefficients (array a) into a PolynomialTransformation. |
209 |
- std::auto_ptr<PolynomialTransformation> transformation(new PolynomialTransformation(m)); |
|
209 |
+ std::unique_ptr<PolynomialTransformation> transformation(new PolynomialTransformation(m)); |
|
210 | 210 |
for (size_t ic = 0; ic <= m; ++ic) { |
211 | 211 |
transformation->setCoefficient(ic, a[ic]); |
212 | 212 |
} |
... | ... |
@@ -23,13 +23,13 @@ ComposedElement::ComposedElement(const container& elements, |
23 | 23 |
ComposedElement::ComposedElement(const name_type& sequence, const Alphabet& alphabet, unsigned sequence_type) |
24 | 24 |
/*throw (UnknownCharacterException)*/ { |
25 | 25 |
this->setSequence(sequence); |
26 |
- std::auto_ptr<sequence_parser_type> parser; |
|
26 |
+ std::unique_ptr<sequence_parser_type> parser; |
|
27 | 27 |
if (sequence_type == TEX_NOTATION_MOLECULE_SEQUENCE_TYPE) { |
28 |
- parser = std::auto_ptr<sequence_parser_type>(new StandardMoleculeSequenceParser); |
|
28 |
+ parser = std::unique_ptr<sequence_parser_type>(new StandardMoleculeSequenceParser); |
|
29 | 29 |
} else { |
30 |
- parser = std::auto_ptr<sequence_parser_type>(new MoleculeSequenceParser); |
|
30 |
+ parser = std::unique_ptr<sequence_parser_type>(new MoleculeSequenceParser); |
|
31 | 31 |
} |
32 |
- this->initializeElements(alphabet, parser); |
|
32 |
+ this->initializeElements(alphabet, std::move(parser) ); |
|
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
ComposedElement::ComposedElement(const std::vector<unsigned int>& decomposition, |
... | ... |
@@ -113,7 +113,7 @@ ComposedElement::getElementAbundance(const name_type& name) const { |
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
|
116 |
-void ComposedElement::initializeElements(const Alphabet& alphabet, std::auto_ptr<sequence_parser_type> parser) |
|
116 |
+void ComposedElement::initializeElements(const Alphabet& alphabet, std::unique_ptr<sequence_parser_type> parser) |
|
117 | 117 |
/*throw (UnknownCharacterException)*/ { |
118 | 118 |
|
119 | 119 |
typedef sequence_parser_type::container parser_container; |
... | ... |
@@ -201,7 +201,7 @@ class ComposedElement : public Element { |
201 | 201 |
* |
202 | 202 |
* @throws UnknownCharacterException if any error happens while parsing molecule's sequence. |
203 | 203 |
*/ |
204 |
- void initializeElements(const Alphabet& alphabet, std::auto_ptr<sequence_parser_type> parser) |
|
204 |
+ void initializeElements(const Alphabet& alphabet, std::unique_ptr<sequence_parser_type> parser) |
|
205 | 205 |
/*throw (UnknownCharacterException)*/; |
206 | 206 |
|
207 | 207 |
void initializeElements(const std::vector<unsigned int>& decomposition, |
... | ... |
@@ -71,14 +71,14 @@ template <typename T> |
71 | 71 |
std::vector<T> getPositiveNeighborhoodSet(T middle, |
72 | 72 |
std::pair<T, T> minMaxElements, T range, T granularity) { |
73 | 73 |
std::vector<T> valuesRange = getNeighborhoodSet(middle, minMaxElements, range, granularity); |
74 |
- valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end()); |
|
74 |
+ valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), [](const T& x) { return x < 0; }, 0), valuesRange.end()); |
|
75 | 75 |
return valuesRange; |
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
template <typename T> |
79 | 79 |
std::vector<T> getPositiveNeighborhoodSet(T middle, T range, T granularity) { |
80 | 80 |
std::vector<T> valuesRange = getNeighborhoodSet(middle, range, granularity); |
81 |
- valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end()); |
|
81 |
+ valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), [](const T& x) { return x < 0; }), valuesRange.end()); |
|
82 | 82 |
return valuesRange; |
83 | 83 |
} |
84 | 84 |
|
... | ... |
@@ -18,7 +18,7 @@ RealMassDecomposer::RealMassDecomposer(const Weights& weights) : |
18 | 18 |
rounding_errors = |
19 | 19 |
DecompUtils::getMinMaxWeightsRoundingErrors(weights); |
20 | 20 |
precision = weights.getPrecision(); |
21 |
- decomposer = std::auto_ptr<integer_decomposer_type>( |
|
21 |
+ decomposer = std::unique_ptr<integer_decomposer_type>( |
|
22 | 22 |
new integer_decomposer_type(weights)); |
23 | 23 |
} |
24 | 24 |
|
... | ... |
@@ -100,7 +100,7 @@ class RealMassDecomposer { |
100 | 100 |
* Decomposer to be used for exact decomposing using |
101 | 101 |
* integer arithmetics. |
102 | 102 |
*/ |
103 |
- std::auto_ptr<integer_decomposer_type> decomposer; |
|
103 |
+ std::unique_ptr<integer_decomposer_type> decomposer; |
|
104 | 104 |
}; |
105 | 105 |
|
106 | 106 |
} // namespace ims |
... | ... |
@@ -50,14 +50,14 @@ public: |
50 | 50 |
* Sets a new Modifier. Assumes ownership. |
51 | 51 |
* @param modifier new Modifier |
52 | 52 |
*/ |
53 |
- virtual void setModifier(std::auto_ptr<Modifier<peaklist_type> > modifier) { |
|
53 |
+ virtual void setModifier(std::unique_ptr<Modifier<peaklist_type> > modifier) { |
|
54 | 54 |
this->modifier = modifier; |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
virtual ~Fragmenter() { } |
58 | 58 |
|
59 | 59 |
protected: |
60 |
- std::auto_ptr<Modifier<peaklist_type> > modifier; |
|
60 |
+ std::unique_ptr<Modifier<peaklist_type> > modifier; |
|
61 | 61 |
}; |
62 | 62 |
|
63 | 63 |
} |
... | ... |
@@ -21,7 +21,7 @@ class MarkovSequenceGenerator : public SequenceGenerator { |
21 | 21 |
|
22 | 22 |
private: |
23 | 23 |
std::vector<Distribution> dists; |
24 |
- std::auto_ptr<Distribution> start_dist; |
|
24 |
+ std::unique_ptr<Distribution> start_dist; |
|
25 | 25 |
DistributedAlphabetType alphabet; |
26 | 26 |
|
27 | 27 |
public: |
... | ... |
@@ -42,7 +42,7 @@ MarkovSequenceGenerator<DistributedAlphabetType>:: |
42 | 42 |
for(size_t i=0; i<alphabet.size(); i++){ |
43 | 43 |
start_p[i] = alphabet.getProbability(alphabet.getName(i)); |
44 | 44 |
} |
45 |
- start_dist = std::auto_ptr<Distribution>(new Distribution(start_p)); |
|
45 |
+ start_dist = std::unique_ptr<Distribution>(new Distribution(start_p)); |
|
46 | 46 |
|
47 | 47 |
|
48 | 48 |
/** matrix **/ |
... | ... |
@@ -37,7 +37,7 @@ class MultiModifier : public Modifier<PeakListType> { |
37 | 37 |
/** |
38 | 38 |
* Adds a modifier |
39 | 39 |
*/ |
40 |
- void addModifier(std::auto_ptr<Modifier<PeakListType> >); |
|
40 |
+ void addModifier(std::unique_ptr<Modifier<PeakListType> >); |
|
41 | 41 |
|
42 | 42 |
private: |
43 | 43 |
void deleteModifiers(); |
... | ... |
@@ -55,7 +55,7 @@ MultiModifier<PeakListType>& MultiModifier<PeakListType>::operator=(const MultiM |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
template <typename PeakListType> |
58 |
-void MultiModifier<PeakListType>::addModifier(std::auto_ptr<Modifier<PeakListType> > modifier) { |
|
58 |
+void MultiModifier<PeakListType>::addModifier(std::unique_ptr<Modifier<PeakListType> > modifier) { |
|
59 | 59 |
modifiers.push_back(modifier.release()); |
60 | 60 |
} |
61 | 61 |
|
... | ... |
@@ -17,7 +17,7 @@ template <typename DistributedAlphabetType > |
17 | 17 |
class RandomSequenceGenerator : public SequenceGenerator{ |
18 | 18 |
|
19 | 19 |
private: |
20 |
- std::auto_ptr<Distribution> dist; |
|
20 |
+ std::unique_ptr<Distribution> dist; |
|
21 | 21 |
DistributedAlphabetType alphabet; |
22 | 22 |
|
23 | 23 |
public: |
... | ... |
@@ -33,7 +33,7 @@ RandomSequenceGenerator<DistributedAlphabetType>::RandomSequenceGenerator(Distri |
33 | 33 |
for(size_t i=0; i<alphabet.size(); i++){ |
34 | 34 |
vec[i] = alphabet.getProbability(alphabet.getName(i)); |
35 | 35 |
} |
36 |
- dist = std::auto_ptr<Distribution>(new Distribution(vec)); |
|
36 |
+ dist = std::unique_ptr<Distribution>(new Distribution(vec)); |
|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
|
... | ... |
@@ -328,7 +328,7 @@ void LinearPointSetMatcherTest::matchAndVerify(ims::LinearPointSetMatcher& lpsm, |
328 | 328 |
CPPUNIT_ASSERT(t.getTranslation() <= translation_limit.second + accuracy); |
329 | 329 |
// in one-to-one case the verification procedure is different... |
330 | 330 |
if (lpsm.one2One()) { |
331 |
- auto_ptr<map<int,int> > m = lpsm.getMapping(); |
|
331 |
+ unique_ptr<map<int,int> > m = lpsm.getMapping(); |
|
332 | 332 |
CPPUNIT_ASSERT( m.get() != 0 ); |
333 | 333 |
verifyOneToOne(pointsets[i], pointsets[j], lpsm.getEpsilon(), t, *m, lpsm.getAbsLimit()); |
334 | 334 |
} else { |
... | ... |
@@ -69,7 +69,7 @@ void MatchMatrixTest::testMatchMatrix() { |
69 | 69 |
mm.unset(1,3); |
70 | 70 |
|
71 | 71 |
|
72 |
- auto_ptr<std::map<int,int> > m1 = mm.countMatches(); |
|
72 |
+ unique_ptr<std::map<int,int> > m1 = mm.countMatches(); |
|
73 | 73 |
CPPUNIT_ASSERT_EQUAL((size_t)5, m1->size()); |
74 | 74 |
CPPUNIT_ASSERT_EQUAL(1, (*m1)[1]); |
75 | 75 |
CPPUNIT_ASSERT_EQUAL(3, (*m1)[3]); |
... | ... |
@@ -77,7 +77,7 @@ void MatchMatrixTest::testMatchMatrix() { |
77 | 77 |
CPPUNIT_ASSERT_EQUAL(5, (*m1)[5]); |
78 | 78 |
CPPUNIT_ASSERT_EQUAL(6, (*m1)[6]); |
79 | 79 |
|
80 |
- auto_ptr<std::map<int,int> > m2 = mm.countMatchesRestrictive(); |
|
80 |
+ unique_ptr<std::map<int,int> > m2 = mm.countMatchesRestrictive(); |
|
81 | 81 |
CPPUNIT_ASSERT_EQUAL((size_t)1, m2->size()); |
82 | 82 |
CPPUNIT_ASSERT_EQUAL(5, (*m2)[5]); |
83 | 83 |
} |
... | ... |
@@ -55,7 +55,7 @@ void ChebyshevFitterTest::testFit() { |
55 | 55 |
a.push_back(2000.0); b.push_back(2000.0); |
56 | 56 |
a.push_back(3000.0); b.push_back(3000.0); |
57 | 57 |
|
58 |
- std::auto_ptr<ims::PolynomialTransformation> pt1 = fitter2.fit(a.begin(), a.end(), b.begin(), b.end()); |
|
58 |
+ std::unique_ptr<ims::PolynomialTransformation> pt1 = fitter2.fit(a.begin(), a.end(), b.begin(), b.end()); |
|
59 | 59 |
|
60 | 60 |
std::vector<double>::const_iterator cit; |
61 | 61 |
for (cit = a.begin(); cit != a.end(); ++cit) { |
... | ... |
@@ -82,7 +82,7 @@ void ChebyshevFitterTest::testFit() { |
82 | 82 |
|
83 | 83 |
// estimate 5th degree polynomial |
84 | 84 |
ims::ChebyshevFitter fitter5(5); |
85 |
- std::auto_ptr<ims::PolynomialTransformation> pt2 = fitter5.fit(a.begin(), a.end(), b.begin(), b.end()); |
|
85 |
+ std::unique_ptr<ims::PolynomialTransformation> pt2 = fitter5.fit(a.begin(), a.end(), b.begin(), b.end()); |
|
86 | 86 |
|
87 | 87 |
// ... and compare to original |
88 | 88 |
for (size_t i = 0; i <= 5; ++i) { |
... | ... |
@@ -41,7 +41,7 @@ void IdentityTransformationTest::testTransform() { |
41 | 41 |
void IdentityTransformationTest::testOutput() { |
42 | 42 |
std::ostringstream oss; |
43 | 43 |
ims::IdentityTransformation id; |
44 |
- std::auto_ptr<ims::Transformation> idp(new ims::IdentityTransformation); |
|
44 |
+ std::unique_ptr<ims::Transformation> idp(new ims::IdentityTransformation); |
|
45 | 45 |
oss << id; |
46 | 46 |
oss << *((ims::IdentityTransformation*)(idp.get())); // TODO hmm ... |
47 | 47 |
cout << oss; |
... | ... |
@@ -62,7 +62,7 @@ void IntensityNormalizerModifierTest::testModify() { |
62 | 62 |
|
63 | 63 |
void IntensityNormalizerModifierTest::testClone() { |
64 | 64 |
ims::IntensityNormalizerModifier<peaklist_t> modifier(1.0); |
65 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
65 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
66 | 66 |
cloned->modify(peaklist); |
67 | 67 |
assertHelp(); |
68 | 68 |
} |
... | ... |
@@ -65,7 +65,7 @@ void MassRangeModifierTest::testModify() { |
65 | 65 |
|
66 | 66 |
void MassRangeModifierTest::testClone() { |
67 | 67 |
ims::MassRangeModifier<peaklist_t> modifier(5.0, 20.0); |
68 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
68 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
69 | 69 |
cloned->modify(peaklist); |
70 | 70 |
assertHelp(); |
71 | 71 |
} |
... | ... |
@@ -66,9 +66,9 @@ void MultiModifierTest::preparePeaklist() { |
66 | 66 |
|
67 | 67 |
void MultiModifierTest::testModify() { |
68 | 68 |
ims::MultiModifier<peaklist_t> modifier; |
69 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
69 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
70 | 70 |
new ims::SortModifier<peaklist_t>)); |
71 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
71 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
72 | 72 |
new ims::UnificationModifier<peaklist_t>)); |
73 | 73 |
modifier.modify(peaklist); |
74 | 74 |
assertHelp(); |
... | ... |
@@ -77,12 +77,12 @@ void MultiModifierTest::testModify() { |
77 | 77 |
|
78 | 78 |
void MultiModifierTest::testClone() { |
79 | 79 |
ims::MultiModifier<peaklist_t> modifier; |
80 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
80 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
81 | 81 |
new ims::SortModifier<peaklist_t>)); |
82 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
82 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
83 | 83 |
new ims::UnificationModifier<peaklist_t>)); |
84 | 84 |
|
85 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
85 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
86 | 86 |
cloned->modify(peaklist); |
87 | 87 |
assertHelp(); |
88 | 88 |
} |
... | ... |
@@ -90,9 +90,9 @@ void MultiModifierTest::testClone() { |
90 | 90 |
|
91 | 91 |
void MultiModifierTest::testAssignment() { |
92 | 92 |
ims::MultiModifier<peaklist_t> modifier, modifier2; |
93 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
93 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
94 | 94 |
new ims::SortModifier<peaklist_t>)); |
95 |
- modifier.addModifier(std::auto_ptr<ims::Modifier<peaklist_t> >( |
|
95 |
+ modifier.addModifier(std::unique_ptr<ims::Modifier<peaklist_t> >( |
|
96 | 96 |
new ims::UnificationModifier<peaklist_t>)); |
97 | 97 |
|
98 | 98 |
modifier2=modifier; |
... | ... |
@@ -67,7 +67,7 @@ void NoiseModifierTest::testModify() { |
67 | 67 |
|
68 | 68 |
void NoiseModifierTest::testClone() { |
69 | 69 |
ims::NoiseModifier<peaklist_t> modifier; |
70 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
70 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
71 | 71 |
cloned->modify(peaklist); |
72 | 72 |
assertHelp(); |
73 | 73 |
} |
... | ... |
@@ -63,7 +63,7 @@ void ShiftModifierTest::testModify() { |
63 | 63 |
|
64 | 64 |
void ShiftModifierTest::testClone() { |
65 | 65 |
ims::ShiftModifier<peaklist_t> modifier(15.0); |
66 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
66 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
67 | 67 |
cloned->modify(peaklist); |
68 | 68 |
assertHelp(); |
69 | 69 |
} |
... | ... |
@@ -73,7 +73,7 @@ void SortModifierTest::testModify() { |
73 | 73 |
|
74 | 74 |
void SortModifierTest::testClone() { |
75 | 75 |
ims::SortModifier<peaklist_t> modifier; |
76 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
76 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
77 | 77 |
cloned->modify(peaklist); |
78 | 78 |
assertHelp(); |
79 | 79 |
} |
... | ... |
@@ -61,7 +61,7 @@ void UnificationModifierTest::testModify() { |
61 | 61 |
|
62 | 62 |
void UnificationModifierTest::testClone() { |
63 | 63 |
ims::UnificationModifier<peaklist_t> modifier; |
64 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
64 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
65 | 65 |
cloned->modify(peaklist); |
66 | 66 |
assertHelp(); |
67 | 67 |
} |
... | ... |
@@ -62,7 +62,7 @@ void VoidModifierTest::testModify() { |
62 | 62 |
|
63 | 63 |
void VoidModifierTest::testClone() { |
64 | 64 |
ims::VoidModifier<peaklist_t> modifier; |
65 |
- std::auto_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
65 |
+ std::unique_ptr<ims::Modifier<peaklist_t> > cloned(modifier.clone()); |
|
66 | 66 |
cloned->modify(peaklist); |
67 | 67 |
assertHelp(); |
68 | 68 |
} |
... | ... |
@@ -26,13 +26,13 @@ private: |
26 | 26 |
typedef MassPeak<int> peak_type; |
27 | 27 |
typedef PeakList<peak_type> peaklist_type; |
28 | 28 |
/** Factory for simple peaklists with masses from 1 to 10. */ |
29 |
- std::auto_ptr<peaklist_type> createPeaklist(); |
|
29 |
+ std::unique_ptr<peaklist_type> createPeaklist(); |
|
30 | 30 |
}; |
31 | 31 |
|
32 | 32 |
CPPUNIT_TEST_SUITE_REGISTRATION( PeakPropertyIteratorTest ); |
33 | 33 |
|
34 |
-std::auto_ptr<PeakPropertyIteratorTest::peaklist_type> PeakPropertyIteratorTest::createPeaklist() { |
|
35 |
- std::auto_ptr<peaklist_type> p(new peaklist_type); |
|
34 |
+std::unique_ptr<PeakPropertyIteratorTest::peaklist_type> PeakPropertyIteratorTest::createPeaklist() { |
|
35 |
+ std::unique_ptr<peaklist_type> p(new peaklist_type); |
|
36 | 36 |
for (int i=1; i<=10; ++i) { |
37 | 37 |
p->push_back(i); |
38 | 38 |
} |
... | ... |
@@ -40,7 +40,7 @@ std::auto_ptr<PeakPropertyIteratorTest::peaklist_type> PeakPropertyIteratorTest: |
40 | 40 |
} |
41 | 41 |
|
42 | 42 |
void PeakPropertyIteratorTest::testInputOutput() { |
43 |
- std::auto_ptr<peaklist_type> pl=createPeaklist(); |
|
43 |
+ std::unique_ptr<peaklist_type> pl=createPeaklist(); |
|
44 | 44 |
peaklist_type::property_iterator<peak_type::MassGetter>::type it; |
45 | 45 |
|
46 | 46 |
int i=1; |
... | ... |
@@ -80,7 +80,7 @@ void PeakPropertyIteratorTest::testInputOutput() { |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
void PeakPropertyIteratorTest::testBidirectionality() { |
83 |
- std::auto_ptr<peaklist_type> pl=createPeaklist(); |
|
83 |
+ std::unique_ptr<peaklist_type> pl=createPeaklist(); |
|
84 | 84 |
peaklist_type::property_iterator<peak_type::MassGetter>::type it,it2; |
85 | 85 |
|
86 | 86 |
int i=10; |
... | ... |
@@ -114,7 +114,7 @@ void PeakPropertyIteratorTest::testBidirectionality() { |
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
void PeakPropertyIteratorTest::testRandomAccess() { |
117 |
- std::auto_ptr<peaklist_type> pl=createPeaklist(); |
|
117 |
+ std::unique_ptr<peaklist_type> pl=createPeaklist(); |
|
118 | 118 |
peaklist_type::property_iterator<peak_type::MassGetter>::type it,it2; |
119 | 119 |
|
120 | 120 |
it=pl->begin<peak_type::MassGetter>(); |
... | ... |
@@ -318,13 +318,13 @@ int main(int argc, char** argv) |
318 | 318 |
|
319 | 319 |
//now build some kind of fragmentizer |
320 | 320 |
cout << "Start building Fragmenter..." << endl; |
321 |
- auto_ptr<Modifier<peaklist_type> > sort_modifier(new SortModifier<peaklist_type>); |
|
322 |
- auto_ptr<Modifier<peaklist_type> > unification_modifier(new UnificationModifier<peaklist_type>); |
|
323 |
- auto_ptr<MultiModifier<peaklist_type> > multi_modifier(new MultiModifier<peaklist_type>); |
|
321 |
+ unique_ptr<Modifier<peaklist_type> > sort_modifier(new SortModifier<peaklist_type>); |
|
322 |
+ unique_ptr<Modifier<peaklist_type> > unification_modifier(new UnificationModifier<peaklist_type>); |
|
323 |
+ unique_ptr<MultiModifier<peaklist_type> > multi_modifier(new MultiModifier<peaklist_type>); |
|
324 | 324 |
multi_modifier->addModifier(sort_modifier); |
325 | 325 |
multi_modifier->addModifier(unification_modifier); |
326 | 326 |
fragmenter_type fragmenter(alphabet, cleavage_chars, prohibition_chars, with_cleavage_char); |
327 |
- fragmenter.setModifier(auto_ptr<Modifier<peaklist_type> >(multi_modifier)); |
|
327 |
+ fragmenter.setModifier(unique_ptr<Modifier<peaklist_type> >(multi_modifier)); |
|
328 | 328 |
cout << "...done\n" << endl; |
329 | 329 |
|
330 | 330 |
|