Index: src/OFMutableSet.h ================================================================== --- src/OFMutableSet.h +++ src/OFMutableSet.h @@ -33,21 +33,21 @@ * @param object The object to remove from the set */ - (void)removeObject: (id)object; /*! - * @brief Removes all objects from the receiver that are in the specified set. + * @brief Removes all objects from the receiver which are in the specified set. * * @param set The set whose objects will be removed from the receiver */ - (void)minusSet: (OFSet*)set; /*! - * @brief Removes all objects from the receiver that are not in the specified + * @brief Removes all objects from the receiver which are not in the specified * set. * - * @param set The set to intersect + * @param set The set to intersect with */ - (void)intersectSet: (OFSet*)set; /*! * @brief Creates a union of the receiver and the specified set. Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -142,10 +142,34 @@ * @return Whether the receiver and the specified set have at least one object * in common */ - (BOOL)intersectsSet: (OFSet*)set; +/*! + * @brief Creates a new set which contains the objects which are in the + * receiver, but not in the specified set. + * + * @param set The set whose objects will not be in the new set + */ +- (OFSet*)setBySubtractingSet: (OFSet*)set; + +/*! + * @brief Creates a new set by creating the intersection of the receiver and + * the specified set. + * + * @param set The set to intersect with + */ +- (OFSet*)setByIntersectingWithSet: (OFString*)set; + +/*! + * @brief Creates a new set by creating the union of the receiver and the + * specified set. + * + * @param set The set to create the union with + */ +- (OFSet*)setByAddingSet: (OFSet*)set; + #ifdef OF_HAVE_BLOCKS /*! * @brief Executes a block for each object in the set. * * @param block The block to execute for each object in the set Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -389,10 +389,46 @@ objc_autoreleasePoolPop(pool); return [element autorelease]; } + +- (OFSet*)setBySubtractingSet: (OFSet*)set +{ + OFMutableSet *new; + + new = [[self mutableCopy] autorelease]; + [new minusSet: set]; + + [new makeImmutable]; + + return new; +} + +- (OFSet*)setByIntersectingWithSet: (OFSet*)set +{ + OFMutableSet *new; + + new = [[self mutableCopy] autorelease]; + [new intersectSet: set]; + + [new makeImmutable]; + + return new; +} + +- (OFSet*)setByAddingSet: (OFSet*)set +{ + OFMutableSet *new; + + new = [[self mutableCopy] autorelease]; + [new unionSet: set]; + + [new makeImmutable]; + + return new; +} #if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block { BOOL stop = NO;