mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
([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:
parent
5054040415
commit
433dd8ef66
1 changed files with 25 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue