Tidyups and implementation of setSet: method

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10010 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-05-22 09:30:07 +00:00
parent 20dc038685
commit e8cb9dcc9d
9 changed files with 78 additions and 38 deletions

View file

@ -470,7 +470,7 @@ static SEL eqSel;
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
index = _count;
@ -540,7 +540,7 @@ static SEL eqSel;
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
index = _count;
@ -653,7 +653,7 @@ static SEL eqSel;
#ifdef GSWARN
if (badComparison == YES)
{
NSWarnMLog(@"Detected bad return value from comparison", 0);
NSWarnMLog(@"Detected bad return value from comparison");
}
#endif
}

View file

@ -610,7 +610,7 @@ SANITY();
if (range.length == 0)
{
NSWarnMLog(@"Attempt to set attribute for zero-length range", 0);
NSWarnMLog(@"Attempt to set attribute for zero-length range");
return;
}
if (attributes == nil)

View file

@ -284,7 +284,7 @@
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
bucket = GSIMapBucketForKey(&map, (GSIMapKey)anObject);

View file

@ -566,7 +566,7 @@ static Class mutableSetClass;
{
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
GSIMapRemoveKey(&map, (GSIMapKey)anObject);
@ -577,21 +577,27 @@ static Class mutableSetClass;
if (other != self)
{
NSEnumerator *e = [other objectEnumerator];
id anObject;
while ((anObject = [e nextObject]) != nil)
if (e != nil)
{
GSIMapNode node;
id anObject;
SEL sel = @selector(nextObject);
IMP imp = [e methodForSelector: sel];
if (anObject == nil)
while ((anObject = (*imp)(e, sel)) != nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
}
}

View file

@ -993,7 +993,7 @@ static NSString *indentStrings[] = {
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
i = [self count];
@ -1026,7 +1026,7 @@ static NSString *indentStrings[] = {
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
c = [self count];
@ -1079,7 +1079,7 @@ static NSString *indentStrings[] = {
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
c = [self count];
@ -1116,7 +1116,7 @@ static NSString *indentStrings[] = {
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
NSWarnMLog(@"attempt to remove nil object");
return;
}
i = [self count];
@ -1362,7 +1362,7 @@ static NSString *indentStrings[] = {
#ifdef GSWARN
if (badComparison == YES)
{
NSWarnMLog(@"Detected bad return value from comparison", 0);
NSWarnMLog(@"Detected bad return value from comparison");
}
#endif
}

View file

@ -861,7 +861,7 @@ static NSString *indentStrings[] = {
#ifdef GSWARN
if (badComparison == YES)
{
NSWarnMLog(@"Detected bad return value from comparison", 0);
NSWarnMLog(@"Detected bad return value from comparison");
}
#endif
}

View file

@ -30,6 +30,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSDebug.h>
@class GSSet;
@class GSMutableSet;
@ -523,20 +524,6 @@ static Class NSMutableSet_concrete_class;
}
}
- (void) unionSet: (NSSet*) other
{
if (other != self)
{
id keys = [other objectEnumerator];
id key;
while ((key = [keys nextObject]))
{
[self addObject: key];
}
}
}
- (void) intersectSet: (NSSet*) other
{
if (other != self)
@ -577,4 +564,38 @@ static Class NSMutableSet_concrete_class;
[self subclassResponsibility: _cmd];
}
- (void) setSet: (NSSet*)other
{
if (other == self)
{
return;
}
if (other == nil)
{
NSWarnMLog(@"Setting mutable set to nil");
[self removeAllObjects];
}
else
{
RETAIN(other); // In case it's held by us
[self removeAllObjects];
[self unionSet: other];
RELEASE(other);
}
}
- (void) unionSet: (NSSet*) other
{
if (other != self)
{
id keys = [other objectEnumerator];
id key;
while ((key = [keys nextObject]))
{
[self addObject: key];
}
}
}
@end