Collaboration diagram for Partitioning:
Partitioning | |
(OLBidirectionalIterator *) | + partitionFrom:to:predicate: |
Partition a range. | |
(OLForwardIterator *) | + stablePartitionFrom:to:predicate: |
Partition a range stably. |
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.
+ (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)
.
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 |
[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.
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 |
[first, last)
where the partition is located
|