Move containsObject: to NSOrderedSet.m. Make additional changes to fix issues pointed out by Fred

This commit is contained in:
Gregory John Casamento 2019-06-11 05:45:37 -04:00
parent c131f7ec34
commit abe0ee3d3d
2 changed files with 9 additions and 21 deletions

View file

@ -218,22 +218,6 @@ static Class mutableSetClass;
return item.obj;
}
- (BOOL) containsObject: (id)anObject
{
NSUInteger i = 0;
for (i = 0; i < [self count]; i++)
{
id obj = [self objectAtIndex: i];
if([anObject isEqual: obj])
{
return YES;
}
}
return NO;
}
/* Designated initialiser */
- (id) initWithObjects: (const id*)objs count: (NSUInteger)c
{
@ -308,6 +292,7 @@ static Class mutableSetClass;
- (void) removeObjectAtIndex: (NSUInteger)index
{
_version++;
GSIArrayRemoveItemAtIndex(&array, index);
}

View file

@ -629,12 +629,16 @@ static SEL rlSel;
return 0;
}
- (BOOL)containsObject:(id)anObject // required override
- (BOOL) containsObject: (id)anObject
{
[self subclassResponsibility: _cmd];
return NO;
NSUInteger i = [self indexOfObject: anObject];
if (i == NSNotFound)
{
return NO;
}
return YES;
}
- (void) enumerateObjectsAtIndexes:(NSIndexSet *)indexSet
options:(NSEnumerationOptions)opts
usingBlock:(GSEnumeratorBlock)aBlock
@ -727,7 +731,6 @@ static SEL rlSel;
return GS_IMMUTABLE(group);
}
- (NSUInteger) indexOfObject:(id)anObject
{
NSUInteger c = [self count];