# HG changeset patch # User Jens Alfke # Date 1208307760 25200 # Node ID c9f2e0c7359a6b46eee21604edf87dcd5d68c302 # Parent 64823cdde6a50ba36265afbc8f31b1435c596c33 Added some set utils. diff -r 64823cdde6a5 -r c9f2e0c7359a CollectionUtils.h --- a/CollectionUtils.h Mon Apr 14 13:58:48 2008 -0700 +++ b/CollectionUtils.h Tue Apr 15 18:02:40 2008 -0700 @@ -45,6 +45,12 @@ @end +@interface NSSet (MYUtils) ++ (NSSet*) my_unionOfSet: (NSSet*)set1 andSet: (NSSet*)set2; ++ (NSSet*) my_differenceOfSet: (NSSet*)set1 andSet: (NSSet*)set2; +@end + + #pragma mark - #pragma mark FOREACH: diff -r 64823cdde6a5 -r c9f2e0c7359a CollectionUtils.m --- a/CollectionUtils.m Mon Apr 14 13:58:48 2008 -0700 +++ b/CollectionUtils.m Tue Apr 15 18:02:40 2008 -0700 @@ -160,6 +160,37 @@ @end + +@implementation NSSet (MYUtils) ++ (NSSet*) my_unionOfSet: (NSSet*)set1 andSet: (NSSet*)set2 +{ + if( set1 == set2 || set2.count==0 ) + return set1; + else if( set1.count==0 ) + return set2; + else { + NSMutableSet *result = [set1 mutableCopy]; + [result unionSet: set2]; + return [result autorelease]; + } +} + ++ (NSSet*) my_differenceOfSet: (NSSet*)set1 andSet: (NSSet*)set2 +{ + if( set1.count==0 || set2.count==0 ) + return set1; + else if( set1==set2 ) + return [NSSet set]; + else { + NSMutableSet *result = [set1 mutableCopy]; + [result minusSet: set2]; + return [result autorelease]; + } +} +@end + + + #import "Test.h" TestCase(CollectionUtils) { diff -r 64823cdde6a5 -r c9f2e0c7359a GraphicsUtils.m --- a/GraphicsUtils.m Mon Apr 14 13:58:48 2008 -0700 +++ b/GraphicsUtils.m Tue Apr 15 18:02:40 2008 -0700 @@ -222,7 +222,7 @@ NSMutableArray *windows = $marray(); for( NSWindow *window in [NSApp windows] ) { id delegate = window.delegate; - if( (window.isVisible || window.isMiniaturized) && [delegate isKindOfClass: klass] ) + if( (window.isVisible || window.isMiniaturized) && (klass==nil || [delegate isKindOfClass: klass]) ) [windows addObject: window]; } return windows;