Topic: Std. doesn't seem to require stable_sort() to be stable!
Author: "Prateek" <kprateek88@gmail.com>
Date: 12 Apr 2005 19:00:06 GMT Raw View
<quote>
17.3.1.1 Summary
1 The Summary provides a synopsis of the category, and introduces the
first-level subclauses. Each subclause also provides a summary, listing
the headers specified in the subclause and the library entities
provided in each header.
2 Paragraphs labelled "Note(s):" or "Example(s):" are informative,
other paragraphs are normative.
</quote>
So this means that a "Notes" paragraph wouldn't be normative.
<quote>
25.3.1.2 stable_sort
template<class RandomAccessIterator>
void stable_sort(RandomAccessIterator first, RandomAccessIterator
last);
template<class RandomAccessIterator, class Compare>
void stable_sort(RandomAccessIterator first, RandomAccessIterator last,
Compare comp);
1 Effects: Sorts the elements in the range [first, last).
2 Complexity: It does at most N(log N)^2 (where N == last - first)
comparisons; if enough extra memory is available, it is N log N.
3 Notes: Stable: the relative order of the equivalent elements is
preserved.
</quote>
The Notes para is informative, and nowhere else is stability mentioned
above.
Also, I just searched for the word "stable" in my copy of the Standard.
and the phrase "Notes: Stable: the relative order of the elements..."
is repeated several times in the Standard library clauses for
describing various functions. How is it that stability is talked about
in the informative paragraph? Or am I missing something obvious?
Prateek Karandikar
-- --
To iterate is human, to recurse divine. -L. Peter Deutsch
-- --
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]