From 22181c5996be5806cd3441c7f0f2f61f6ef829f4 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 1 Mar 2012 21:55:41 +0000 Subject: [PATCH] Monotone-Parent: b1c2ca52ec5ce74741f62b95f3be18e4d6c99949 Monotone-Revision: ef48f0aa709b92913c131c539cb55562e8c56ebf Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-01T21:55:41 --- ChangeLog | 5 +++++ SoObjects/SOGo/NSArray+Utilities.h | 2 ++ SoObjects/SOGo/NSArray+Utilities.m | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) 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