implement -removeAllObjects

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38477 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-05-05 16:01:21 +00:00
parent dee7d0fae5
commit ce991d339a

View file

@ -637,6 +637,38 @@ static Class GSInlineArrayClass;
return self;
}
- (void) removeAllObjects
{
NSUInteger pos;
if ((pos = _count) > 0)
{
#if GS_WITH_GC == 0
IMP rel = 0;
Class last = Nil;
#endif
_version++;
_count = 0;
while (pos-- > 0)
{
#if GS_WITH_GC == 0
id o = _contents_array[pos];
Class c = object_getClass(o);
if (c != last)
{
last = c;
rel = [o methodForSelector: @selector(release)];
}
(*rel)(o, @selector(release));
#endif
_contents_array[pos] = nil;
}
_version++;
}
}
- (void) removeLastObject
{
_version++;