Index: src/OFMutableSet.h ================================================================== --- src/OFMutableSet.h +++ src/OFMutableSet.h @@ -50,6 +50,13 @@ * set. * * \param set The set to intersect */ - (void)intersectSet: (OFSet*)set; + +/** + * \brief Creates a union of the receiver and the specified set. + * + * \param set The set to create the union with + */ +- (void)unionSet: (OFSet*)set; @end Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -63,10 +63,22 @@ for (i = 0; i < count; i++) if (![set containsObject: cArray[i]]) [self removeObject: cArray[i]]; + [pool release]; +} + +- (void)unionSet: (OFSet*)set +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFEnumerator *enumerator = [set objectEnumerator]; + id object; + + while ((object = [enumerator nextObject]) != nil) + [self addObject: object]; + [pool release]; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects Index: tests/OFSet.m ================================================================== --- tests/OFSet.m +++ tests/OFSet.m @@ -84,12 +84,14 @@ TEST(@"-[intersectSet:]", R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz", nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz", nil])]) - [mutableSet addObject: @"baz"]; - [mutableSet addObject: @"x"]; + TEST(@"-[unionSet:]", + R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar", + nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz", + @"bar", @"x", nil])]) #ifdef OF_HAVE_FAST_ENUMERATION ok = YES; i = 0;