ObjectiveLib  1.0.0
Partitioning
Algorithms

Algorithms for partitioning. More...

Collaboration diagram for Partitioning:

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:
firstthe first in the range to partition
lastone position beyond the last in the range to partition
predthe 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:
firstthe first in the range to partition
lastone position beyond the last in the range to partition
predthe 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 Sat Feb 15 2014 07:45:33, © 2004-2007 Will Mason