diff --git a/ChangeLog b/ChangeLog index adadedfc1..9e3e49f28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-03-01 Wolfgang Sourdeau + + * SoObjects/SOGo/NSArray+Utilities.m (-[NSMutableArray + removeDoubles]): new method removing doublons. + 2012-03-01 Francis Lachapelle * UI/WebServerResources/ContactsUI.js (appendAddressBook): assume diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index adf773809..d5ee37c8f 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -70,6 +70,8 @@ - (void) addObjectUniquely: (id) object; +- (void) removeDoubles; + - (BOOL) hasRangeIntersection: (NSRange) testRange; @end diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index 61aea0c40..6f2a56449 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -324,4 +324,20 @@ return response; } +- (void) removeDoubles +{ + NSMutableDictionary *valueDicts; + NSNull *dummy; + NSUInteger count, max; + + dummy = [NSNull null]; + + max = [self count]; + valueDicts = [NSMutableDictionary dictionaryWithCapacity: max]; + + for (count = 0; count < max; count++) + [valueDicts setObject: dummy forKey: [self objectAtIndex: count]]; + [self setArray: [valueDicts allKeys]]; +} + @end