Re: counting objects in array
Re: counting objects in array
- Subject: Re: counting objects in array
- From: Prachi Gauriar <email@hidden>
- Date: Wed, 21 Jul 2004 20:36:42 -0500
On Jul 20, 2004, at 6:08 PM, Jonathan Jackel wrote:
On Jul 19, 2004, at 9:10 PM, Koen van der Drift wrote:
I came up with the following code to count the occurences of objects
in an array. In this snippet I count the names of the persons in an
array (how many Micks, Keiths, Charlies, etc) It works, but I was
wondering if this is a 'good' approach.
This was written in, but I think it's right.
You can scrunch it a bit with some modest C tricks and avoiding the
repetitive calls to -allKeys:
(I forgot to send this to the list and Koen)
<snip />
I missed the original message, so this might not be appropriate. What
about using a counted set?
NSCountedSet *nameCountedSet = [NSCountedSet setWithArray:namesArray];
Definitely wins in the lowest line count category.
-Prachi
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.