mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Implement more methods
This commit is contained in:
parent
fc31e7a37c
commit
f45a231211
1 changed files with 52 additions and 3 deletions
|
@ -891,6 +891,7 @@ static SEL rlSel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overridable method...
|
||||||
- (void)insertObject:(id)object atIndex:(NSUInteger)index
|
- (void)insertObject:(id)object atIndex:(NSUInteger)index
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
@ -922,9 +923,47 @@ static SEL rlSel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeObject:(id)object
|
- (void)removeObject:(id)anObject
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
NSUInteger i;
|
||||||
|
|
||||||
|
if (anObject == nil)
|
||||||
|
{
|
||||||
|
NSWarnMLog(@"attempt to remove nil object");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i = [self count];
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
IMP rem = 0;
|
||||||
|
IMP get = [self methodForSelector: oaiSel];
|
||||||
|
BOOL (*eq)(id, SEL, id)
|
||||||
|
= (BOOL (*)(id, SEL, id))[anObject methodForSelector: eqSel];
|
||||||
|
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
id o = (*get)(self, oaiSel, i);
|
||||||
|
|
||||||
|
if (o == anObject || (*eq)(anObject, eqSel, o) == YES)
|
||||||
|
{
|
||||||
|
if (rem == 0)
|
||||||
|
{
|
||||||
|
rem = [self methodForSelector: remSel];
|
||||||
|
/*
|
||||||
|
* We need to retain the object so that when we remove the
|
||||||
|
* first equal object we don't get left with a bad object
|
||||||
|
* pointer for later comparisons.
|
||||||
|
*/
|
||||||
|
RETAIN(anObject);
|
||||||
|
}
|
||||||
|
(*rem)(self, remSel, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rem != 0)
|
||||||
|
{
|
||||||
|
RELEASE(anObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeObjectAtIndex:(NSUInteger)integer
|
- (void)removeObjectAtIndex:(NSUInteger)integer
|
||||||
|
@ -946,7 +985,17 @@ static SEL rlSel;
|
||||||
|
|
||||||
- (void)removeAllObjects
|
- (void)removeAllObjects
|
||||||
{
|
{
|
||||||
|
NSUInteger c = [self count];
|
||||||
|
|
||||||
|
if (c > 0)
|
||||||
|
{
|
||||||
|
IMP remLast = [self methodForSelector: rlSel];
|
||||||
|
|
||||||
|
while (c--)
|
||||||
|
{
|
||||||
|
(*remLast)(self, rlSel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)replaceObjectAtIndex:(NSUInteger)index
|
- (void)replaceObjectAtIndex:(NSUInteger)index
|
||||||
|
|
Loading…
Reference in a new issue