• 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: NSArray merge sorting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray merge sorting


  • Subject: Re: NSArray merge sorting
  • From: Jonathan Hess <email@hidden>
  • Date: Mon, 20 Apr 2009 17:39:56 -0700


On Apr 20, 2009, at 5:32 PM, Greg Guerin wrote:


Would NSSet cut the mustard here?


NSArray allows duplicate items; NSSet does not. What do you propose happen if one or both NSArray inputs have items that compare as equal?

Algorithmically speaking, a merge sort from two inputs into a new output seems pretty simple. Simply choose the lesser of the two available next-items and append it to the new array. Or if both next-items are equal, choose one arbitrarily.

You should probably choose the one that came first in the original array. Merge sort should be order preserving, and even though the objects are ordered the same with respect to the comparison function, their identities my be different and their relative ordering should be preserved.


Jon Hess


-- GG

_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: NSArray merge sorting
      • From: David Scheidt <email@hidden>
References: 
 >Re: NSArray merge sorting (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: NSArray merge sorting
  • Next by Date: Re: OpenGL
  • Previous by thread: Re: NSArray merge sorting
  • Next by thread: Re: NSArray merge sorting
  • Index(es):
    • Date
    • Thread