mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Bufix sorting array.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15273 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
627d189b1f
commit
3eb602cc99
3 changed files with 25 additions and 20 deletions
|
@ -1,7 +1,12 @@
|
|||
2002-12-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSArray.m: ([removeObjectsFromIndices:numIndices:])
|
||||
bugfix for sorting by Kelvin Sherlock.
|
||||
|
||||
2002-12-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSThread.m: Fix race condition firing perform holder.
|
||||
Fix supplied by {hilip Derrin.
|
||||
Fix supplied by Philip Derrin.
|
||||
|
||||
2002-12-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -1519,7 +1519,7 @@ static int compare(id elem1, id elem2, void* context)
|
|||
unsigned val = indices[from++];
|
||||
|
||||
i = to;
|
||||
while (i > 0 && sorted[i] > val)
|
||||
while (i > 0 && sorted[i-1] > val)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
|
|
@ -91,24 +91,24 @@ main()
|
|||
printf("Index of identical object is %d\n", p);
|
||||
|
||||
NSCParameterAssert([c lastObject]);
|
||||
printf("Classname at index 2 is %s\n", [[c objectAtIndex:2] name]);
|
||||
printf("Class at index 2 is %s\n", [[[c objectAtIndex:2] description] cString]);
|
||||
|
||||
printf("Forward enumeration\n");
|
||||
enumerator = [e objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Reverse enumeration\n");
|
||||
enumerator = [e reverseObjectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
{
|
||||
// Sending messages to elements
|
||||
[c makeObjectsPerform:@selector(name)];
|
||||
[c makeObjectsPerform:@selector(description)];
|
||||
|
||||
//[c makeObjectsPerform:@selector(isEqual:) withObject: @"NSArray"];
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
if ([f isEqualToArray: c])
|
||||
|
@ -234,7 +234,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -insertObject: [NSMutableArray class] atIndex: 2\n");
|
||||
|
@ -242,7 +242,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -removeObject: [NSObject class]\n");
|
||||
|
@ -276,7 +276,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -removeObjectIdenticalTo: [NSArray class]\n");
|
||||
|
@ -284,7 +284,7 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -removeObjectAtIndex: 2\n");
|
||||
|
@ -292,19 +292,19 @@ main()
|
|||
|
||||
enumerator = [f objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -removeObjectsFromIndices: {7,4,1,3,5,0,6} "
|
||||
"numIndices: 6\n");
|
||||
enumerator = [g objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
[g removeObjectsFromIndices: ind numIndices: 7];
|
||||
enumerator = [g objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
if ([f isEqualToArray: g])
|
||||
|
@ -316,12 +316,12 @@ main()
|
|||
printf("Receiver array\n");
|
||||
enumerator = [h objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
printf("Removing objects in this array\n");
|
||||
enumerator = [c objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
[h removeObjectsInArray: c];
|
||||
|
@ -343,19 +343,19 @@ main()
|
|||
printf("Method -replaceObjectAtIndex: 2 withObject:[NSString class]\n");
|
||||
enumerator = [c objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
[c replaceObjectAtIndex: 2 withObject:[NSString class]];
|
||||
enumerator = [c objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
|
||||
printf("Method -setArray:\n");
|
||||
[h setArray: f];
|
||||
enumerator = [h objectEnumerator];
|
||||
while ((i = [enumerator nextObject]))
|
||||
printf("%s ", [i name]);
|
||||
printf("%s ", [[i description] cString]);
|
||||
printf("\n");
|
||||
if ([h isEqualToArray: h])
|
||||
printf("-setArray worked properly\n");
|
||||
|
|
Loading…
Reference in a new issue