Added some set utils.
1.1 --- a/CollectionUtils.h Mon Apr 14 13:58:48 2008 -0700
1.2 +++ b/CollectionUtils.h Tue Apr 15 18:02:40 2008 -0700
1.3 @@ -45,6 +45,12 @@
1.4 @end
1.5
1.6
1.7 +@interface NSSet (MYUtils)
1.8 ++ (NSSet*) my_unionOfSet: (NSSet*)set1 andSet: (NSSet*)set2;
1.9 ++ (NSSet*) my_differenceOfSet: (NSSet*)set1 andSet: (NSSet*)set2;
1.10 +@end
1.11 +
1.12 +
1.13 #pragma mark -
1.14 #pragma mark FOREACH:
1.15
2.1 --- a/CollectionUtils.m Mon Apr 14 13:58:48 2008 -0700
2.2 +++ b/CollectionUtils.m Tue Apr 15 18:02:40 2008 -0700
2.3 @@ -160,6 +160,37 @@
2.4 @end
2.5
2.6
2.7 +
2.8 +@implementation NSSet (MYUtils)
2.9 ++ (NSSet*) my_unionOfSet: (NSSet*)set1 andSet: (NSSet*)set2
2.10 +{
2.11 + if( set1 == set2 || set2.count==0 )
2.12 + return set1;
2.13 + else if( set1.count==0 )
2.14 + return set2;
2.15 + else {
2.16 + NSMutableSet *result = [set1 mutableCopy];
2.17 + [result unionSet: set2];
2.18 + return [result autorelease];
2.19 + }
2.20 +}
2.21 +
2.22 ++ (NSSet*) my_differenceOfSet: (NSSet*)set1 andSet: (NSSet*)set2
2.23 +{
2.24 + if( set1.count==0 || set2.count==0 )
2.25 + return set1;
2.26 + else if( set1==set2 )
2.27 + return [NSSet set];
2.28 + else {
2.29 + NSMutableSet *result = [set1 mutableCopy];
2.30 + [result minusSet: set2];
2.31 + return [result autorelease];
2.32 + }
2.33 +}
2.34 +@end
2.35 +
2.36 +
2.37 +
2.38 #import "Test.h"
2.39
2.40 TestCase(CollectionUtils) {
3.1 --- a/GraphicsUtils.m Mon Apr 14 13:58:48 2008 -0700
3.2 +++ b/GraphicsUtils.m Tue Apr 15 18:02:40 2008 -0700
3.3 @@ -222,7 +222,7 @@
3.4 NSMutableArray *windows = $marray();
3.5 for( NSWindow *window in [NSApp windows] ) {
3.6 id delegate = window.delegate;
3.7 - if( (window.isVisible || window.isMiniaturized) && [delegate isKindOfClass: klass] )
3.8 + if( (window.isVisible || window.isMiniaturized) && (klass==nil || [delegate isKindOfClass: klass]) )
3.9 [windows addObject: window];
3.10 }
3.11 return windows;