• 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
mutable keys in NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mutable keys in NSMutableDictionary


  • Subject: mutable keys in NSMutableDictionary
  • From: Ivan Kourtev <email@hidden>
  • Date: Tue, 7 Oct 2003 11:00:57 -0400

Hello,

I am wondering if anyone can provide an explanation behind the philosophy of the NSMutableDictionary class? Here is a brief description of the situation:

I would like to have an NSMutableDictionary which stores a very large graph structure (millions of vertices and tens of millions of edges). The keys are vertex objects and the values are ordered vectors objects -- the elements of the vectors are other vertices that the key is connected to. Every vertex object manages a lot of data but the data identifying a unique vertex (so one can distinguish among vertices via isEqual messages) is very small and never changes after a vertex instance creation.

The problem is that -- as I understand from the documentation -- NSMutableDictionary creates its own copies of the keys internally (one has to provide a copyWithZone function for that which I have written). Therefore, it seems that after an insertion of a key-value pair, one can never get the actual internal key objects. I do, however, need these in the process of dynamically building the graph stored in the NSMutableDictionary. Otherwise, it appears I will have essentially duplicates of every key which will amount to a lot of memory.

I can think of ways around this restriction (such as not actually creating a key copy in the copyWithZone) but I suspect there may be a better solution? Am I missing something, a different dictionary object perhaps more suitable for my needs as described? Maybe there is a bigger issue here -- I admit I don't understand the philosophy behind the design decision to have the local copies of keys in the NSMutableDictionary class? Can anyone explain or point me to a good source of information (I have most Cocoa books and looked through apple's docs as well but didn't find much).

It seems a class called CFDictionary does what I need...but I've never done anything with any CF..., don't know what these are for, and whether one is supposed to use them at all?

Any help greatly appreciated. Thank you and happy coding!
_______________________________________________
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.

  • Follow-Ups:
    • Re: mutable keys in NSMutableDictionary
      • From: Ali Ozer <email@hidden>
    • Re: mutable keys in NSMutableDictionary
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: NSTask
  • Next by Date: Re: NSTask
  • Previous by thread: [OT] Building a MachO internet plugin that works with Safari ?
  • Next by thread: Re: mutable keys in NSMutableDictionary
  • Index(es):
    • Date
    • Thread