From ec8b29cdf1d1be133d56e3681dd61e4a6ec02411 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 19 Jul 2014 00:35:45 +0000 Subject: [PATCH] [stdlib] Fix the public interface of partition It should not take the predicate as inout! Swift SVN r20193 --- stdlib/core/Algorithm.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stdlib/core/Algorithm.swift b/stdlib/core/Algorithm.swift index 8d6e6845c42..2177d728b09 100644 --- a/stdlib/core/Algorithm.swift +++ b/stdlib/core/Algorithm.swift @@ -96,12 +96,21 @@ func _insertionSort< /// [start..idx), pivot ,[idx..end) public func partition< C: MutableCollectionType where C.Index: RandomAccessIndexType +>( + inout elements: C, + range: Range, + var less: (C.Generator.Element, C.Generator.Element)->Bool +) -> C.Index { + return _partition(&elements, range, &less) +} + +public func _partition< + C: MutableCollectionType where C.Index: RandomAccessIndexType >( inout elements: C, range: Range, inout less: (C.Generator.Element, C.Generator.Element)->Bool ) -> C.Index { - _precondition( range.startIndex != range.endIndex, "Can't partition an empty range") @@ -165,7 +174,7 @@ func _quickSortImpl< } // Partition and sort. - let part_idx : C.Index = partition(&elements, range, &less) + let part_idx : C.Index = _partition(&elements, range, &less) _quickSortImpl(&elements, range.startIndex..