aboutsummaryrefslogtreecommitdiffstats
path: root/src/lesson40_algo12.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lesson40_algo12.cpp')
-rw-r--r--src/lesson40_algo12.cpp39
1 files changed, 1 insertions, 38 deletions
diff --git a/src/lesson40_algo12.cpp b/src/lesson40_algo12.cpp
index 2e8580c..23603bc 100644
--- a/src/lesson40_algo12.cpp
+++ b/src/lesson40_algo12.cpp
@@ -232,7 +232,7 @@ namespace hoare2 {
using namespace impl_common;
/**
- * Hoare alike partitioning of range [b..e).
+ * Hoare alike quicksort of range [b..e).
*
* Difference to Hoare's partitioning is using dedicated loops for each side of the pivot
* to move the element over to the other side.
@@ -247,43 +247,6 @@ namespace hoare2 {
* @param array
* @param b left start index, inclusive
* @param e right end index, exclusive
- * @return pivot index
- */
- template<typename V>
- size_t partition(std::vector<V>& array, size_t b, size_t e) {
- // stick with using references for comparison, no copy
- size_t l = (b + e - 1 ) / 2; // pivot index
- for(size_t i = b; i < l; ) {
- if( array[i] > array[l] ) {
- array.insert(array.begin() + e, array[i]);
- array.erase( array.begin() + i );
- --l;
- } else {
- ++i;
- }
- }
- for(size_t i = l+1; i < e; ) {
- if( array[i] < array[l] ) {
- array.insert(array.begin() + b, array[i]);
- ++i;
- ++l;
- array.erase( array.begin() + i );
- } else {
- ++i;
- }
- }
- return l;
- }
-
- /**
- * Hoare alike quicksort of range [b..e).
- *
- * Quicksort by Tony Hoare in 1959, published 1961.
- *
- * @tparam V
- * @param array
- * @param b left start index, inclusive
- * @param e right end index, exclusive
* @return number of partitioning
*/
template<typename V>