diff --git a/ChangeLog b/ChangeLog index 413f74173..63e24fd61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 16 15:35:00 1999 Richard Frith-Macdonald + + * Source/NSArray.m: ([-removeObjectsFromIndices:]) rewrite to + work according to spec. + * Testing/nsarray.m: Fixed check on joining strings. + Mon Feb 15 06:14:00 1999 Richard Frith-Macdonald * Source/include/NSDebug.h: Declare strerror() if not known to system diff --git a/Source/NSArray.m b/Source/NSArray.m index 7a12917f2..ed01857f4 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -911,8 +911,45 @@ static NSString *indentStrings[] = { - (void) removeObjectsFromIndices: (unsigned*)indices numIndices: (unsigned)count { - while (count--) - [self removeObjectAtIndex:indices[count]]; + if (count > 0) + { + unsigned sorted[count]; + unsigned to = 0; + unsigned from = 0; + unsigned i; + + while (from < count) + { + unsigned val = indices[from++]; + + i = to; + while (i > 0 && sorted[i] > val) + { + i--; + } + if (i == to) + { + sorted[to++] = val; + } + else if (sorted[i] < val) + { + unsigned j = to++; + + i++; + while (j > i) + { + sorted[j] = sorted[j-1]; + j--; + } + sorted[i] = val; + } + } + + while (to--) + { + [self removeObjectAtIndex: indices[to]]; + } + } } - (void) removeObjectsInArray: (NSArray*)otherArray diff --git a/Testing/nsarray.m b/Testing/nsarray.m index 77e20cda7..c08253e9a 100644 --- a/Testing/nsarray.m +++ b/Testing/nsarray.m @@ -185,7 +185,7 @@ main() // Joining string elements printf("Method: -componentsJoinedByString:\n"); i = [c componentsJoinedByString: @"/"]; - if ([i isEqual: @"NSObject/NSArray/NSMutableArray"]) + if ([i isEqual: @"//"]) printf("%s is correct\n", [i cString]); else {