mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
formatting/coding style fixups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35574 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b9b63476ef
commit
8ec0deff44
8 changed files with 871 additions and 771 deletions
|
@ -797,9 +797,10 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
_version++;
|
||||
if ((1 < _count) && (NULL != compare))
|
||||
{
|
||||
GSSortUnstable(_contents_array, NSMakeRange(0,_count), (id)compare, GSComparisonTypeFunction, context);
|
||||
}
|
||||
{
|
||||
GSSortUnstable(_contents_array, NSMakeRange(0,_count), (id)compare,
|
||||
GSComparisonTypeFunction, context);
|
||||
}
|
||||
_version++;
|
||||
}
|
||||
|
||||
|
@ -808,34 +809,34 @@ static Class GSInlineArrayClass;
|
|||
{
|
||||
_version++;
|
||||
if ((1 < _count) && (NULL != comparator))
|
||||
{
|
||||
if (options & NSSortStable)
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortStableConcurrent(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortStable(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortUnstableConcurrent(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
if (options & NSSortStable)
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortStableConcurrent(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortStable(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortUnstable(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortUnstableConcurrent(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortUnstable(_contents_array, NSMakeRange(0,_count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_version++;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ SwapObjects(id * o1, id * o2)
|
|||
#ifndef GS_DISABLE_QUICKSORT
|
||||
static void
|
||||
_GSQuickSort(id *objects,
|
||||
NSRange sortRange,
|
||||
id comparisonEntity,
|
||||
GSComparisonType type,
|
||||
void *context)
|
||||
NSRange sortRange,
|
||||
id comparisonEntity,
|
||||
GSComparisonType type,
|
||||
void *context)
|
||||
{
|
||||
if (sortRange.length > 1)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ _GSQuickSort(id *objects,
|
|||
@end
|
||||
|
||||
@implementation GSQuickSortPlaceHolder
|
||||
+ (void)load
|
||||
+ (void) load
|
||||
{
|
||||
_GSSortUnstable = _GSQuickSort;
|
||||
}
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
#ifndef GS_DISABLE_SHELLSORT
|
||||
void
|
||||
_GSShellSort(id *objects,
|
||||
NSRange sortRange,
|
||||
id comparisonEntity,
|
||||
GSComparisonType type,
|
||||
void *context)
|
||||
NSRange sortRange,
|
||||
id comparisonEntity,
|
||||
GSComparisonType type,
|
||||
void *context)
|
||||
{
|
||||
/* Shell sort algorithm taken from SortingInAction - a NeXT example */
|
||||
#define STRIDE_FACTOR 3 // good value for stride factor is not well-understood
|
||||
|
@ -73,7 +73,9 @@ _GSShellSort(id *objects,
|
|||
id a = objects[d + stride];
|
||||
id b = objects[d];
|
||||
NSComparisonResult r;
|
||||
r = GSCompareUsingDescriptorOrComparator(a, b, comparisonEntity, context);
|
||||
|
||||
r = GSCompareUsingDescriptorOrComparator(a, b,
|
||||
comparisonEntity, context);
|
||||
if (r < 0)
|
||||
{
|
||||
#ifdef GSWARN
|
||||
|
@ -82,7 +84,7 @@ _GSShellSort(id *objects,
|
|||
badComparison = YES;
|
||||
}
|
||||
#endif
|
||||
objects[d+stride] = b;
|
||||
objects[d + stride] = b;
|
||||
objects[d] = a;
|
||||
if (stride > d)
|
||||
{
|
||||
|
@ -117,7 +119,7 @@ _GSShellSort(id *objects,
|
|||
@end
|
||||
|
||||
@implementation GSShellSortPlaceHolder
|
||||
+ (void)load
|
||||
+ (void) load
|
||||
{
|
||||
_GSSortUnstable = _GSShellSort;
|
||||
}
|
||||
|
|
|
@ -47,28 +47,35 @@ typedef NSUInteger GSComparisonType;
|
|||
* may or may not be implemented by one of the sorting implementations in
|
||||
* GNUstep.
|
||||
*/
|
||||
extern void (*_GSSortUnstable)(id* buffer, NSRange range, id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
extern void (*_GSSortUnstable)(id *buffer, NSRange range, id comparisonEntity,
|
||||
GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* This is the internal prototype of an stable, non-concurrency safe sorting
|
||||
* function that can be used either through NSComparator or NSSortDescriptor.
|
||||
* It may or may not be implemented by one of the sorting implementations in
|
||||
* GNUstep.
|
||||
*/
|
||||
extern void (*_GSSortStable)(id* buffer, NSRange range, id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
extern void (*_GSSortStable)(id *buffer, NSRange range, id comparisonEntity,
|
||||
GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* This is the internal prototype of an unstable, concurrency safe sorting
|
||||
* function that can be used either through NSComparator or NSSortDescriptor.
|
||||
* It may or may not be implemented by one of the sorting implementations in
|
||||
* GNUstep.
|
||||
*/
|
||||
extern void (*_GSSortUnstableConcurrent)(id* buffer, NSRange range, id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
extern void (*_GSSortUnstableConcurrent)(id *buffer, NSRange range,
|
||||
id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* This is the internal prototype of an stable, concurrency safe sorting
|
||||
* function that can be used either through NSComparator or NSSortDescriptor.
|
||||
* It may or may not be implemented by one of the sorting implementations in
|
||||
* GNUstep.
|
||||
*/
|
||||
extern void (*_GSSortStableConcurrent)(id* buffer, NSRange range, id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
extern void (*_GSSortStableConcurrent)(id *buffer, NSRange range,
|
||||
id comparisonEntity, GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* GSSortUnstable() uses the above prototypes to provide sorting that does not
|
||||
|
@ -76,15 +83,16 @@ extern void (*_GSSortStableConcurrent)(id* buffer, NSRange range, id comparisonE
|
|||
* available, it will fall through to stable sorting.
|
||||
*/
|
||||
void
|
||||
GSSortUnstable(id* buffer, NSRange range, id sortDecriptorOrCompatator, GSComparisonType cmprType, void *context);
|
||||
GSSortUnstable(id *buffer, NSRange range, id sortDecriptorOrCompatator,
|
||||
GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* GSSortStable() uses one of the internal sorting algorithms to provide stable
|
||||
* sorting. If no stable sorting method is available, it raises an exception.
|
||||
*/
|
||||
void
|
||||
GSSortStable(id* buffer, NSRange range, id sortDecriptorOrCompatator, GSComparisonType cmprType, void *context);
|
||||
|
||||
GSSortStable(id *buffer, NSRange range, id sortDecriptorOrCompatator,
|
||||
GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* GSSortUnstableConcurrent() uses the above prototypes to provide sorting that
|
||||
|
@ -94,7 +102,8 @@ GSSortStable(id* buffer, NSRange range, id sortDecriptorOrCompatator, GSComparis
|
|||
* concurrent sorting.
|
||||
*/
|
||||
void
|
||||
GSSortUnstableConcurrent(id* buffer, NSRange range, id sortDecriptorOrCompatator, GSComparisonType cmprType, void *context);
|
||||
GSSortUnstableConcurrent(id *buffer, NSRange range,
|
||||
id sortDecriptorOrCompatator, GSComparisonType cmprType, void *context);
|
||||
|
||||
/**
|
||||
* GSSortStableConcurrent() uses one of the internal sorting algorithms to
|
||||
|
@ -102,7 +111,8 @@ GSSortUnstableConcurrent(id* buffer, NSRange range, id sortDecriptorOrCompatator
|
|||
* algorithm is available, it falls through to non-concurrent GSSortStable().
|
||||
*/
|
||||
void
|
||||
GSSortStableConcurrent(id* buffer, NSRange range, id sortDecriptorOrCompatator, GSComparisonType cmprType, void *context);
|
||||
GSSortStableConcurrent(id *buffer, NSRange range, id sortDecriptorOrCompatator,
|
||||
GSComparisonType cmprType, void *context);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -112,7 +122,8 @@ GSSortStableConcurrent(id* buffer, NSRange range, id sortDecriptorOrCompatator,
|
|||
* This function is provided using the implementation of the timsort algorithm.
|
||||
*/
|
||||
NSUInteger
|
||||
GSRightInsertionPointForKeyInSortedRange(id key, id* buffer, NSRange range, NSComparator comparator);
|
||||
GSRightInsertionPointForKeyInSortedRange(id key, id *buffer,
|
||||
NSRange range, NSComparator comparator);
|
||||
|
||||
/**
|
||||
* This function finds the proper point for inserting a new key into a sorted
|
||||
|
@ -121,27 +132,34 @@ GSRightInsertionPointForKeyInSortedRange(id key, id* buffer, NSRange range, NSCo
|
|||
* This function is provided using the implementation of the timsort algorithm.
|
||||
*/
|
||||
NSUInteger
|
||||
GSLeftInsertionPointForKeyInSortedRange(id key, id* buffer, NSRange range, NSComparator comparator);
|
||||
GSLeftInsertionPointForKeyInSortedRange(id key, id* buffer,
|
||||
NSRange range, NSComparator comparator);
|
||||
|
||||
/**
|
||||
* Convenience function to operate with sort descriptors, comparator blocks and functions.
|
||||
* Convenience function to operate with sort descriptors,
|
||||
* comparator blocks and functions.
|
||||
*/
|
||||
static inline NSComparisonResult
|
||||
GSCompareUsingDescriptorOrComparator(id first, id second, id descOrComp, GSComparisonType cmprType, void* context)
|
||||
GSCompareUsingDescriptorOrComparator(id first, id second, id descOrComp,
|
||||
GSComparisonType cmprType, void* context)
|
||||
{
|
||||
|
||||
switch (cmprType)
|
||||
{
|
||||
case GSComparisonTypeSortDescriptor:
|
||||
return [(NSSortDescriptor*)descOrComp compareObject: first toObject: second];
|
||||
case GSComparisonTypeComparatorBlock:
|
||||
return CALL_BLOCK(((NSComparator)descOrComp), first, second);
|
||||
case GSComparisonTypeFunction:
|
||||
return ((NSInteger (*)(id, id, void *))descOrComp)(first, second, context);
|
||||
default:
|
||||
[NSException raise: @"NSInternalInconstitencyException"
|
||||
format: @"Invalid comparison type"];
|
||||
}
|
||||
{
|
||||
case GSComparisonTypeSortDescriptor:
|
||||
return [(NSSortDescriptor*)descOrComp compareObject: first
|
||||
toObject: second];
|
||||
case GSComparisonTypeComparatorBlock:
|
||||
return CALL_BLOCK(((NSComparator)descOrComp), first, second);
|
||||
|
||||
case GSComparisonTypeFunction:
|
||||
return ((NSInteger (*)(id, id, void *))descOrComp)(first,
|
||||
second, context);
|
||||
|
||||
default:
|
||||
[NSException raise: @"NSInternalInconstitencyException"
|
||||
format: @"Invalid comparison type"];
|
||||
}
|
||||
// Not reached:
|
||||
return 0;
|
||||
}
|
||||
|
|
1191
Source/GSTimSort.m
1191
Source/GSTimSort.m
File diff suppressed because it is too large
Load diff
218
Source/NSArray.m
218
Source/NSArray.m
|
@ -54,6 +54,7 @@
|
|||
#import "GSFastEnumeration.h"
|
||||
#import "GSDispatch.h"
|
||||
#import "GSSorting.h"
|
||||
|
||||
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
||||
{
|
||||
if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES)
|
||||
|
@ -1080,8 +1081,9 @@ compare(id elem1, id elem2, void* context)
|
|||
* according to a sort with comparator. This invokes
|
||||
* -sortedArrayUsingFunction:context:hint: with a nil hint.
|
||||
*/
|
||||
- (NSArray*) sortedArrayUsingFunction: (NSComparisonResult(*)(id,id,void*))comparator
|
||||
context: (void*)context
|
||||
- (NSArray*) sortedArrayUsingFunction:
|
||||
(NSComparisonResult(*)(id,id,void*))comparator
|
||||
context: (void*)context
|
||||
{
|
||||
return [self sortedArrayUsingFunction: comparator context: context hint: nil];
|
||||
}
|
||||
|
@ -1101,9 +1103,10 @@ compare(id elem1, id elem2, void* context)
|
|||
* is passed two objects to compare, and the context as the third
|
||||
* argument. The hint argument is currently ignored, and may be nil.
|
||||
*/
|
||||
- (NSArray*) sortedArrayUsingFunction: (NSComparisonResult(*)(id,id,void*))comparator
|
||||
context: (void*)context
|
||||
hint: (NSData*)hint
|
||||
- (NSArray*) sortedArrayUsingFunction:
|
||||
(NSComparisonResult(*)(id,id,void*))comparator
|
||||
context: (void*)context
|
||||
hint: (NSData*)hint
|
||||
{
|
||||
NSMutableArray *sortedArray;
|
||||
|
||||
|
@ -1116,7 +1119,7 @@ compare(id elem1, id elem2, void* context)
|
|||
|
||||
|
||||
- (NSArray*) sortedArrayWithOptions: (NSSortOptions)options
|
||||
usingComparator:(NSComparator)comparator
|
||||
usingComparator: (NSComparator)comparator
|
||||
{
|
||||
NSMutableArray *sortedArray;
|
||||
|
||||
|
@ -1138,67 +1141,77 @@ compare(id elem1, id elem2, void* context)
|
|||
usingComparator: (NSComparator)comparator
|
||||
{
|
||||
if (range.length == 0)
|
||||
{
|
||||
return options & NSBinarySearchingInsertionIndex ? range.location : NSNotFound;
|
||||
}
|
||||
{
|
||||
return options & NSBinarySearchingInsertionIndex
|
||||
? range.location : NSNotFound;
|
||||
}
|
||||
if (range.length == 1)
|
||||
{
|
||||
switch (CALL_BLOCK(comparator, key, [self objectAtIndex: range.location]))
|
||||
{
|
||||
case NSOrderedSame:
|
||||
return range.location;
|
||||
case NSOrderedAscending:
|
||||
return options & NSBinarySearchingInsertionIndex ? range.location : NSNotFound;
|
||||
case NSOrderedDescending:
|
||||
return options & NSBinarySearchingInsertionIndex ? (range.location + 1) : NSNotFound;
|
||||
default:
|
||||
// Shouldn't happen
|
||||
return NSNotFound;
|
||||
switch (CALL_BLOCK(comparator, key, [self objectAtIndex: range.location]))
|
||||
{
|
||||
case NSOrderedSame:
|
||||
return range.location;
|
||||
case NSOrderedAscending:
|
||||
return options & NSBinarySearchingInsertionIndex
|
||||
? range.location : NSNotFound;
|
||||
case NSOrderedDescending:
|
||||
return options & NSBinarySearchingInsertionIndex
|
||||
? (range.location + 1) : NSNotFound;
|
||||
default:
|
||||
// Shouldn't happen
|
||||
return NSNotFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSUInteger index = NSNotFound;
|
||||
NSUInteger count = [self count];
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
[self getObjects: objects];
|
||||
// We use the timsort galloping to find the insertion index:
|
||||
if (options & NSBinarySearchingLastEqual)
|
||||
{
|
||||
index = GSRightInsertionPointForKeyInSortedRange(key, objects, range, comparator);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Left insertion is our default
|
||||
index = GSLeftInsertionPointForKeyInSortedRange(key, objects, range, comparator);
|
||||
}
|
||||
GS_ENDIDBUF()
|
||||
NSUInteger index = NSNotFound;
|
||||
NSUInteger count = [self count];
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
|
||||
// If we were looking for the insertion point, we are done here
|
||||
if (options & NSBinarySearchingInsertionIndex)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
[self getObjects: objects];
|
||||
// We use the timsort galloping to find the insertion index:
|
||||
if (options & NSBinarySearchingLastEqual)
|
||||
{
|
||||
index = GSRightInsertionPointForKeyInSortedRange(key,
|
||||
objects, range, comparator);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Left insertion is our default
|
||||
index = GSLeftInsertionPointForKeyInSortedRange(key,
|
||||
objects, range, comparator);
|
||||
}
|
||||
GS_ENDIDBUF()
|
||||
|
||||
// Otherwise, we need need another equality check in order to know whether
|
||||
// we need return NSNotFound.
|
||||
// If we were looking for the insertion point, we are done here
|
||||
if (options & NSBinarySearchingInsertionIndex)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
if (options & NSBinarySearchingLastEqual)
|
||||
{
|
||||
// For search from the right, the equal object would be the one before the
|
||||
// index, but only if it's not at the very beginning of the range (though
|
||||
// that might not actually be possible, it's better to check nonetheless).
|
||||
if (index > range.location)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
/* Otherwise, we need need another equality check in order to
|
||||
* know whether we need return NSNotFound.
|
||||
*/
|
||||
|
||||
if (options & NSBinarySearchingLastEqual)
|
||||
{
|
||||
/* For search from the right, the equal object would be
|
||||
* the one before the index, but only if it's not at the
|
||||
* very beginning of the range (though that might not
|
||||
* actually be possible, it's better to check nonetheless).
|
||||
*/
|
||||
if (index > range.location)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* For a search from the left, we'd have the correct index anyways. Check
|
||||
* whether it's equal to the key and return NSNotFound otherwise
|
||||
*/
|
||||
return (NSOrderedSame == CALL_BLOCK(comparator,
|
||||
key, [self objectAtIndex: index]) ? index : NSNotFound);
|
||||
}
|
||||
/*
|
||||
* For a search from the left, we'd have the correct index anyways. Check
|
||||
* whether it's equal to the key and return NSNotFound otherwise
|
||||
*/
|
||||
return (NSOrderedSame == CALL_BLOCK(comparator, key, [self objectAtIndex: index]) ? index : NSNotFound);
|
||||
}
|
||||
// Never reached
|
||||
return NSNotFound;
|
||||
}
|
||||
|
@ -2516,61 +2529,68 @@ compare(id elem1, id elem2, void* context)
|
|||
context: (void*)context
|
||||
{
|
||||
NSUInteger count = [self count];
|
||||
|
||||
if ((1 < count) && (NULL != compare))
|
||||
{
|
||||
NSArray *res = nil;
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
[self getObjects: objects];
|
||||
{
|
||||
NSArray *res = nil;
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
[self getObjects: objects];
|
||||
|
||||
GSSortUnstable(objects, NSMakeRange(0,count), (id)compare, GSComparisonTypeFunction, context);
|
||||
GSSortUnstable(objects,
|
||||
NSMakeRange(0,count), (id)compare, GSComparisonTypeFunction, context);
|
||||
|
||||
res = [[NSArray alloc] initWithObjects: objects count: count];
|
||||
[self setArray: res];
|
||||
RELEASE(res);
|
||||
GS_ENDIDBUF();
|
||||
}
|
||||
res = [[NSArray alloc] initWithObjects: objects count: count];
|
||||
[self setArray: res];
|
||||
RELEASE(res);
|
||||
GS_ENDIDBUF();
|
||||
}
|
||||
}
|
||||
|
||||
- (void) sortWithOptions: (NSSortOptions)options
|
||||
usingComparator: (NSComparator)comparator
|
||||
{
|
||||
NSUInteger count = [self count];
|
||||
if ((1 < count) && (NULL != comparator))
|
||||
{
|
||||
NSArray *res = nil;
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
[self getObjects: objects];
|
||||
|
||||
if (options & NSSortStable)
|
||||
if ((1 < count) && (NULL != comparator))
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortStableConcurrent(objects, NSMakeRange(0,count), (id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortStable(objects, NSMakeRange(0,count), (id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
NSArray *res = nil;
|
||||
GS_BEGINIDBUF(objects, count);
|
||||
[self getObjects: objects];
|
||||
|
||||
if (options & NSSortStable)
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortStableConcurrent(objects, NSMakeRange(0,count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortStable(objects, NSMakeRange(0,count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortUnstableConcurrent(objects, NSMakeRange(0,count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortUnstable(objects, NSMakeRange(0,count),
|
||||
(id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
res = [[NSArray alloc] initWithObjects: objects count: count];
|
||||
[self setArray: res];
|
||||
RELEASE(res);
|
||||
GS_ENDIDBUF();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options & NSSortConcurrent)
|
||||
{
|
||||
GSSortUnstableConcurrent(objects, NSMakeRange(0,count), (id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortUnstable(objects, NSMakeRange(0,count), (id)comparator, GSComparisonTypeComparatorBlock, NULL);
|
||||
}
|
||||
}
|
||||
res = [[NSArray alloc] initWithObjects: objects count: count];
|
||||
[self setArray: res];
|
||||
RELEASE(res);
|
||||
GS_ENDIDBUF();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sortUsingComparator: (NSComparator)comparator
|
||||
- (void) sortUsingComparator: (NSComparator)comparator
|
||||
{
|
||||
[self sortWithOptions: 0 usingComparator: comparator];
|
||||
}
|
||||
|
|
|
@ -218,65 +218,73 @@ void
|
|||
|
||||
// Sorting functions that select the adequate algorithms
|
||||
void
|
||||
GSSortUnstable(id* buffer, NSRange range, id descriptorOrComparator, GSComparisonType type, void* context)
|
||||
GSSortUnstable(id* buffer, NSRange range, id descriptorOrComparator,
|
||||
GSComparisonType type, void* context)
|
||||
{
|
||||
if (NULL != _GSSortUnstable)
|
||||
{
|
||||
_GSSortUnstable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortUnstable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
else if (NULL != _GSSortStable)
|
||||
{
|
||||
_GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: @"NSInternalInconsistencyException"
|
||||
format: @"The GNUstep-base library was compiled without sorting support."];
|
||||
}
|
||||
{
|
||||
[NSException raise: @"NSInternalInconsistencyException" format:
|
||||
@"The GNUstep-base library was compiled without sorting support."];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GSSortStable(id* buffer, NSRange range, id descriptorOrComparator, GSComparisonType type, void* context)
|
||||
GSSortStable(id* buffer, NSRange range, id descriptorOrComparator,
|
||||
GSComparisonType type, void* context)
|
||||
{
|
||||
if (NULL != _GSSortStable)
|
||||
{
|
||||
_GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: @"NSInternalInconsistencyException"
|
||||
format: @"The GNUstep-base library was compiled without a stable sorting algorithm."];
|
||||
}
|
||||
{
|
||||
[NSException raise: @"NSInternalInconsistencyException" format:
|
||||
@"The GNUstep-base library was compiled without a"
|
||||
@" stable sorting algorithm."];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GSSortStableConcurrent(id* buffer, NSRange range, id descriptorOrComparator, GSComparisonType type, void* context)
|
||||
GSSortStableConcurrent(id* buffer, NSRange range, id descriptorOrComparator,
|
||||
GSComparisonType type, void* context)
|
||||
{
|
||||
if (NULL != _GSSortStableConcurrent)
|
||||
{
|
||||
_GSSortStableConcurrent(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortStableConcurrent(buffer, range, descriptorOrComparator,
|
||||
type, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
GSSortStable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GSSortUnstableConcurrent(id* buffer, NSRange range, id descriptorOrComparator, GSComparisonType type, void* context)
|
||||
GSSortUnstableConcurrent(id* buffer, NSRange range, id descriptorOrComparator,
|
||||
GSComparisonType type, void* context)
|
||||
{
|
||||
if (NULL != _GSSortUnstableConcurrent)
|
||||
{
|
||||
_GSSortUnstableConcurrent(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortUnstableConcurrent(buffer, range, descriptorOrComparator,
|
||||
type, context);
|
||||
}
|
||||
else if (NULL != _GSSortStableConcurrent)
|
||||
{
|
||||
_GSSortStableConcurrent(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
_GSSortStableConcurrent(buffer, range, descriptorOrComparator,
|
||||
type, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSSortUnstable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
{
|
||||
GSSortUnstable(buffer, range, descriptorOrComparator, type, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -401,6 +409,4 @@ SortRange(id *objects, NSRange range, id *descriptors,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -302,6 +302,8 @@ GSPathHandling("right");
|
|||
PASS_EQUAL([url host], nil, "host of data URL is nil");
|
||||
PASS_EQUAL([url resourceSpecifier], @",a23", "resourceSpecifier of data URL");
|
||||
PASS_EQUAL([url absoluteString], @"data:,a23", "can get string of data URL");
|
||||
url = [NSURL URLWithString: @"data:,%2A"];
|
||||
PASS_EQUAL([url resourceSpecifier], @",%2A", "resourceSpecifier escape OK");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue