2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #import "NSSet+enumerator.h"
25 @implementation NSSet(enumerator)
27 - (id)initWithObjectsFromEnumerator:(NSEnumerator *)_enumerator {
28 NSMutableSet *set = nil;
30 set = [[NSMutableSet alloc] initWithObjectsFromEnumerator:_enumerator];
31 self = [self initWithSet:set];
32 [set release]; set = nil;
38 - (NSArray *)mappedArrayUsingSelector:(SEL)_selector {
42 set = [self mappedSetUsingSelector:_selector];
44 array = [[NSArray allocWithZone:[self zone]]
45 initWithObjectsFromEnumerator:[set objectEnumerator]];
48 return [array autorelease];
50 - (NSArray *)mappedArrayUsingSelector:(SEL)_selector withObject:(id)_object {
54 set = [self mappedSetUsingSelector:_selector withObject:_object];
56 array = [[NSArray allocWithZone:[self zone]]
57 initWithObjectsFromEnumerator:[set objectEnumerator]];
60 return [array autorelease];
63 - (NSSet *)mappedSetUsingSelector:(SEL)_selector {
64 NSMutableSet *set = [NSMutableSet setWithCapacity:[self count]];
65 NSEnumerator *e = [self objectEnumerator];
68 while ((object = [e nextObject])) {
69 object = [object performSelector:_selector];
71 [set addObject:object ? object : [NSNull null]];
75 - (NSSet *)mappedSetUsingSelector:(SEL)_selector withObject:(id)_object {
76 NSMutableSet *set = [NSMutableSet setWithCapacity:[self count]];
77 NSEnumerator *e = [self objectEnumerator];
80 while ((object = [e nextObject])) {
81 object = [object performSelector:_selector withObject:_object];
83 [set addObject:object ? object : [NSNull null]];
90 @implementation NSMutableSet(enumerator)
92 - (id)initWithObjectsFromEnumerator:(NSEnumerator *)_enumerator {
93 if ((self = [self init])) {
96 while ((obj = [_enumerator nextObject]))
104 void __link_NGExtensions_NSSetEnumerator() {
105 __link_NGExtensions_NSSetEnumerator();