Improve vec partition and partitioned method doc.

Explicitly note in vec `partition` and `partitioned` that the left and
right parts each map to satisfying and non-satisfying elements.
This commit is contained in:
Felix S. Klock II
2014-02-28 14:07:42 +01:00
parent 31e9c947a3
commit daa6da766a

View File

@@ -1223,10 +1223,8 @@ impl<'a, T: TotalOrd> ImmutableTotalOrdVector<T> for &'a [T] {
/// Extension methods for vectors containing `Clone` elements. /// Extension methods for vectors containing `Clone` elements.
pub trait ImmutableCloneableVector<T> { pub trait ImmutableCloneableVector<T> {
/** /// Partitions the vector into two vectors `(A,B)`, where all
* Partitions the vector into those that satisfies the predicate, and /// elements of `A` satisfy `f` and all elements of `B` do not.
* those that do not.
*/
fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]); fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]);
/// Create an iterator that yields every possible permutation of the /// Create an iterator that yields every possible permutation of the
@@ -1394,9 +1392,10 @@ pub trait OwnedVector<T> {
* Like `filter()`, but in place. Preserves order of `v`. Linear time. * Like `filter()`, but in place. Preserves order of `v`. Linear time.
*/ */
fn retain(&mut self, f: |t: &T| -> bool); fn retain(&mut self, f: |t: &T| -> bool);
/** /**
* Partitions the vector into those that satisfies the predicate, and * Partitions the vector into two vectors `(A,B)`, where all
* those that do not. * elements of `A` satisfy `f` and all elements of `B` do not.
*/ */
fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]); fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]);