• 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: Looking for an Ordered Dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for an Ordered Dictionary


  • Subject: Re: Looking for an Ordered Dictionary
  • From: Brian Webster <email@hidden>
  • Date: Tue, 9 Apr 2002 09:33:56 -0500

On Tuesday, April 9, 2002, at 08:37 AM, cocoa-dev-
email@hidden wrote:

I'm seeking some technique to hold a set of key/value pairs but
keep them IN ORDER. I would use NSDictionary but the keys are
not returned/stored in the order in which they are added - it is
an unordered collection.

I have a similar setup in one of my apps, and the way I did it was to have an object that holds both an NSArray and an NSDictionary. Whenever a key/value pair is stored, I put the key/value pair into the dictionary as normal and then insert the key into the array in sorted order. That way I can iterate the sorted array and get back the key/value pairs from the dictionary in sorted order. There may be some open code somewhere that does this, but it's not very hard to implement.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Prev by Date: ObjC and C++
  • Next by Date: Re: ObjC and C++
  • Previous by thread: Re: Looking for an Ordered Dictionary
  • Next by thread: Re: Fop with Cocoa
  • Index(es):
    • Date
    • Thread