Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

stable_partition()

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