Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -182,10 +182,24 @@ * * @param set The set to create the union with */ - (OFSet*)setByAddingSet: (OFSet*)set; +/*! + * @brief Returns an array of all objects in the set. + * + * @return An array of all objects in the set + */ +- (OFArray*)allObjects; + +/*! + * @brief Returns an arbitrary object in the set. + * + * @return An arbitrary object in the set + */ +- (id)anyObject; + #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 @@ -451,10 +451,28 @@ [new makeImmutable]; return new; } + +- (OFArray*)allObjects +{ + void *pool = objc_autoreleasePoolPush(); + OFArray *ret = [[[self objectEnumerator] allObjects] retain]; + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} + +- (id)anyObject +{ + void *pool = objc_autoreleasePoolPush(); + id ret = [[[self objectEnumerator] nextObject] retain]; + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} #if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block { bool stop = false;