From 69ba1ee04d537c95b5dfc4d57506f7278ebdc94e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 27 Dec 2009 13:58:00 +0000 Subject: Some more code format fixes. svn-id: r46641 --- common/algorithm.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/common/algorithm.h b/common/algorithm.h index 4224ef0e90..d730a3ada2 100644 --- a/common/algorithm.h +++ b/common/algorithm.h @@ -147,13 +147,13 @@ Op for_each(In first, In last, Op f) { } template -unsigned distance(T * first, T * last) { +unsigned int distance(T *first, T *last) { return last - first; } template -unsigned distance(T first, T last) { - unsigned n = 0; +unsigned int distance(T first, T last) { + unsigned int n = 0; while (first != last) { ++n; ++first; @@ -162,13 +162,13 @@ unsigned distance(T first, T last) { } template -T * _sort_choose_pivot(T * first, T * last) { +T *sortChoosePivot(T *first, T *last) { return first + distance(first, last) / 2; } template -T _sort_choose_pivot(T first, T last) { - unsigned n = distance(first, last); +T sortChoosePivot(T first, T last) { + unsigned int n = distance(first, last); n /= 2; while (n--) ++first; @@ -176,7 +176,7 @@ T _sort_choose_pivot(T first, T last) { } template -T _sort_partition(T first, T last, T pivot, StrictWeakOrdering &comp) { +T sortPatition(T first, T last, T pivot, StrictWeakOrdering &comp) { --last; SWAP(*pivot, *last); @@ -197,25 +197,22 @@ T _sort_partition(T first, T last, T pivot, StrictWeakOrdering &comp) { * Simple sort function, modeled after std::sort. * It compares data with the given comparator object comp. */ - template void sort(T first, T last, StrictWeakOrdering comp) { if (first == last) return; - T pivot = _sort_choose_pivot(first, last); - pivot = _sort_partition(first, last, pivot, comp); + T pivot = sortChoosePivot(first, last); + pivot = sortPatition(first, last, pivot, comp); sort(first, pivot, comp); sort(++pivot, last, comp); } /** * Simple sort function, modeled after std::sort. - * Use it like this: sort(container.begin(), container.end()). */ - template -void sort(T * first, T * last) { +void sort(T *first, T *last) { sort(first, last, Common::Less()); } -- cgit v1.2.3