• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Binary search on sorted NSArray in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Binary search on sorted NSArray in Cocoa?


  • Subject: RE: Binary search on sorted NSArray in Cocoa?
  • From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>
  • Date: Wed, 7 Jan 2009 07:32:54 -0500
  • Thread-topic: Binary search on sorted NSArray in Cocoa?

Ken Thomases wrote on Tuesday, January 06, 2009 11:24 PM:

> On Jan 6, 2009, at 10:42 AM, Karan, Cem (Civ, ARL/CISD) wrote:
>
> > I know I'm being pedantic, but just to make sure, will the
> following
> > code work?
> >
> > 	// mySortedArray is an NSArray of NSString instances
> that has been
> > sorted
> > 	// via caseInsensitiveCompare:.  [...]
> >
> > 	CFRange arrayRange;
> > 	arrayRange.location = 0;
> > 	arrayRange.length = [mySortedArray count];
> >
> > 	CFIndex stringIndex;
> > 	stringIndex = CFArrayBSearchValues(	mySortedArray,
> > 							arrayRange,
> > 							myString,
> > 							CFStringCompare,
> >
> > kCFCompareForcedOrdering);
>
> If the array has been sorted with caseInsensitiveCompare:,
> then you need to provide string comparison flags to match.
> You would need
> kCFCompareCaseInsensitive|kCFCompareNonliteral.  Passing
> kCFCompareForcedOrdering when you didn't use
> NSForcedOrderingSearch when originally sorting the array
> seems like asking for trouble, too.

Hmmm, it sounds like I'm going to be doing a LOT of automated fuzz
testing of my code then.  Thanks for the help!

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

References: 
 >Binary search on sorted NSArray in Cocoa? (From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>)
 >Re: Binary search on sorted NSArray in Cocoa? (From: "Adam R. Maxwell" <email@hidden>)
 >RE: Binary search on sorted NSArray in Cocoa? (From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>)
 >Re: Binary search on sorted NSArray in Cocoa? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Cocoa Client/Server App
  • Next by Date: Re: Cocoa Client/Server App
  • Previous by thread: Re: Binary search on sorted NSArray in Cocoa?
  • Next by thread: Printing PDF Documentation
  • Index(es):
    • Date
    • Thread