Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

stable_sort()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

Generic algorithm for sorting collections of entities

Synopsis

#include <algorithm>

namespace std {
  template <class RandomAccessIterator>
  void stable_sort(RandomAccessIterator start, 
                   RandomAccessIterator finish);

  template <class RandomAccessIterator, class Compare>
  void stable_sort(RandomAccessIterator start,
                   RandomAccessIterator finish, Compare comp);
}

Description

The stable_sort() algorithm sorts the elements in the range [start, finish) in ascending order. The first version of the algorithm uses operator<() for the sort. The second version uses the function object comp.

The stable_sort() algorithm is considered stable because the relative order of equivalent elements is maintained.

Complexity

stable_sort() does approximately N * (log(N))2 comparisons, where N equals finish - start. The algorithm calls std::get_temporary_buffer<>() to obtain extra memory. If enough extra memory is available, it does at most N * log(N) comparisons (i.e., the same as sort()).

Example

See Also

sort(), partial_sort(), partial_sort_copy(), get_temporary_buffer()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 25.3.1.2



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.