mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix quicksort implementation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a4140c8f51
commit
7f177becc5
2 changed files with 11 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
2012-09-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSQuickSort.m: Fixed this to compile and (apparently) work.
|
||||
|
||||
2012-09-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure.ac: Change sort selection to use shellsort by default and
|
||||
|
|
|
@ -62,7 +62,7 @@ _GSQuickSort(id *objects,
|
|||
|
||||
while (left < right)
|
||||
{
|
||||
if (GSCompareUsingDescriptorOrComparator(left, right,
|
||||
if (GSCompareUsingDescriptorOrComparator(objects[left], pivot,
|
||||
comparisonEntity, type, context) == NSOrderedDescending)
|
||||
{
|
||||
SwapObjects(&objects[left], &objects[--right]);
|
||||
|
@ -74,10 +74,12 @@ _GSQuickSort(id *objects,
|
|||
}
|
||||
|
||||
SwapObjects(&objects[--left], &objects[sortRange.location]);
|
||||
SortObjectsWithDescriptor(objects, NSMakeRange(sortRange.location, left
|
||||
- sortRange.location), sortDescriptor);
|
||||
SortObjectsWithDescriptor(objects, NSMakeRange(right,
|
||||
NSMaxRange(sortRange) - right), sortDescriptor);
|
||||
_GSQuickSort(objects,
|
||||
NSMakeRange(sortRange.location, left - sortRange.location),
|
||||
comparisonEntity, type, context);
|
||||
_GSQuickSort(objects,
|
||||
NSMakeRange(right, NSMaxRange(sortRange) - right),
|
||||
comparisonEntity, type, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue