@@ -19,10 +19,11 @@ #define OF_MUTABLE_SET_M #import "OFMutableSet.h" #import "OFDictionary.h" #import "OFNull.h" +#import "OFArray.h" #import "OFAutoreleasePool.h" @implementation OFMutableSet - (void)addObject: (id)object { @@ -37,10 +38,37 @@ { [dictionary removeObjectForKey: object]; mutations++; } + +- (void)minusSet: (OFSet*)set +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFEnumerator *enumerator = [set objectEnumerator]; + id object; + + while ((object = [enumerator nextObject]) != nil) + [self removeObject: object]; + + [pool release]; +} + +- (void)intersectSet: (OFSet*)set +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFArray *objects = [dictionary allKeys]; + id *cArray = [objects cArray]; + size_t count = [objects count]; + size_t i; + + for (i = 0; i < count; i++) + if (![set containsObject: cArray[i]]) + [self removeObject: cArray[i]]; + + [pool release]; +} - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count {