([IndexedCollection -removeObject:]): Now removes *all* instances of

ANOBJECT, not just one.
([IndexedCollection -replaceObject:withObject:]): Now replaces *all*
instances of OLDOBJECT, not just one.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1303 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-03-30 19:04:35 +00:00
parent 5054040415
commit 433dd8ef66

View file

@ -428,15 +428,36 @@
- (void) removeObject: anObject - (void) removeObject: anObject
{ {
int index = [self indexOfObject: anObject]; int index;
if (index != NO_INDEX)
/* Retain the object. Yuck, but necessary in case the array holds
the last reference to anObject. */
/* xxx Is there an alternative to this expensive retain/release? */
[anObject retain];
for (index = [self indexOfObject: anObject];
index != NO_INDEX;
index = [self indexOfObject: anObject])
[self removeObjectAtIndex: index]; [self removeObjectAtIndex: index];
[anObject release];
} }
- (void) replaceObject: oldObject withObject: newObject - (void) replaceObject: oldObject withObject: newObject
{ {
int i = [self indexOfObject: oldObject]; int index;
[self replaceObjectAtIndex: i withObject: newObject];
/* Retain the object. Yuck, but necessary in case the array holds
the last reference to anObject. */
/* xxx Is there an alternative to this expensive retain/release? */
[oldObject retain];
for (index = [self indexOfObject: oldObject];
index != NO_INDEX;
index = [self indexOfObject: oldObject])
[self replaceObjectAtIndex: index withObject: newObject];
[oldObject release];
} }
@end @end