mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
20dc038685
commit
e8cb9dcc9d
9 changed files with 78 additions and 38 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue