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_partition()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

An algorithm that places all of the entities that satisfy the given predicate before all of the entities that do not, while maintaining the relative order of elements in each group

Synopsis

#include <algorithm>

namespace std {
  template <class BidirectionalIterator, class Predicate>
  BidirectionalIterator
  stable_partition(BidirectionalIterator start,
                   BidirectionalIterator finish,
                   Predicate pred);
}

Description

For the range [start, finish), the stable_partition() algorithm places all elements that satisfy pred before all elements that do not satisfy it. It returns an iterator i that is one past the end of the group of elements that satisfies pred. The relative order of the elements in both groups is maintained.

The partition() algorithm can be used when it is not necessary to maintain the relative order of elements within the groups that do and do not match the predicate.

Complexity

The stable_partition() algorithm does at most (finish - start) * log(finish - start) swaps and applies the predicate exactly finish - start times.

Example

See Also

partition()

Standards Conformance

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



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.