Binary search on sorted NSArray in Cocoa?
Binary search on sorted NSArray in Cocoa?
- Subject: Binary search on sorted NSArray in Cocoa?
- From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>
- Date: Tue, 6 Jan 2009 08:16:29 -0500
- Thread-topic: Binary search on sorted NSArray in Cocoa?
I have an NSArray of unique NSString instances that I have sorted. I am looking for the neighbors of a specific string within the array, which basically means finding the string's index, and then looking at the objects ahead and behind the string. So far, so good; I can use indexOfObject to find the string in the array, but that is slow as it seems to assume an unsorted array. My question is, does NSArray already have a binary search method defined on it in a category somewhere? If it does, I'd rather use that.
Thanks,
Cem Karan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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