Counting NSMutableSet
Counting NSMutableSet
- Subject: Counting NSMutableSet
- From: "Mark Hill" <email@hidden>
- Date: Tue, 15 May 2007 12:45:47 +0100
Is there an efficient way of identifying the number of elements in an
NSMutableSet. The count function only returns the "uniqueness" of
members rather than the total.
At the moment I'm using an enumerator with an accumulating int, thus:
NSMutableSet *mySet;
mySet = [self mutableSetValueForKey: @"Entity"];
NSEnumerator *enumerator = [mySet objectEnumerator];
id value;
int count = 0;
while ((value = [enumerator nextObject])) {
count++;
}
NSLog(@"elements in set %i", count);
}
But this seems rather expensive to my mind. Surely there's a more efficient way?
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden