Partitioning
[Algorithms]

Collaboration diagram for Partitioning:

Algorithms for partitioning. More...

Partitioning

(OLBidirectionalIterator *) + partitionFrom:to:predicate:
 Partition a range.
(OLForwardIterator *) + stablePartitionFrom:to:predicate:
 Partition a range stably.

Detailed Description

Algorithms for partitioning.

Partition algorithms divide a range into two groups: one group satisfies a given predicate, and the other group doesn't. There is a simple partitioning algorithm, and also a more complex stable partitioning algorithm for use when preserving relative order is important.

See also:
OLAlgorithm

Function Documentation

+ (OLBidirectionalIterator*) partitionFrom: (OLBidirectionalIterator *)  first
to: (OLBidirectionalIterator *)  last
predicate: (id< OLBoolUnaryFunction >)  pred 

Partition a range.

This message reorders the elements in the range [first, last) so that all elements which satisfy the predicate pred precede all elements which do not. An iterator is returned that points to the location of the partition in the sequence. That is, for the returned iterator middle the predicate returns YES for every element in the range [first, middle) and NO for every element in the range [middle, last).

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
first the first in the range to partition
last one position beyond the last in the range to partition
pred the predicate that is used to define the partition
Returns:
an iterator pointing to the location in the range [first, last) where the partition is located

+ (OLForwardIterator*) stablePartitionFrom: (OLForwardIterator *)  first
to: (OLForwardIterator *)  last
predicate: (id< OLBoolUnaryFunction >)  pred 

Partition a range stably.

This message is very similar to the message partitionFrom:to:predicate: except that the partition is created stably. That is, the relative order of elements is preserved after the partition is created.

Parameters:
first the first in the range to partition
last one position beyond the last in the range to partition
pred the predicate that is used to define the partition
Returns:
an iterator pointing to the location in the range [first, last) where the partition is located


ObjectiveLibGenerated Sun Apr 22 15:18:02 2007, © 2004-2007 Will Mason
SourceForge.net Logo