From 196050305c6f34aa3c945b1b07935c101f1a6755 Mon Sep 17 00:00:00 2001 From: Satyarth Agrahari Date: Sat, 15 May 2021 10:50:02 +0530 Subject: [PATCH 1/2] adding time complexity for partition_in_place iter method --- library/core/src/iter/traits/iterator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index da9e5fde7ccec..43d60a4ed76c8 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1849,6 +1849,8 @@ pub trait Iterator { /// /// The relative order of partitioned items is not maintained. /// + /// Time Complexity: *O*(*N*) + /// /// See also [`is_partitioned()`] and [`partition()`]. /// /// [`is_partitioned()`]: Iterator::is_partitioned From 85e417718403cc0a8b058585fb8633b4698ea3e2 Mon Sep 17 00:00:00 2001 From: Satyarth Agrahari Date: Tue, 18 May 2021 07:59:16 +0530 Subject: [PATCH 2/2] adding algorithm explanation for partition_in_place iter method and bounding complexity to current implementation --- library/core/src/iter/traits/iterator.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 43d60a4ed76c8..7ba2dfc994189 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1849,6 +1849,10 @@ pub trait Iterator { /// /// The relative order of partitioned items is not maintained. /// + /// # Current implementation + /// Current algorithms tries finding the first element for which the predicate evaluates + /// to false, and the last element for which it evaluates to true and repeatedly swaps them. + /// /// Time Complexity: *O*(*N*) /// /// See also [`is_partitioned()`] and [`partition()`].