|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What is System.Collection.Specialized.OrderedDictionary - .net 2.0 msdnin .net 2.0 I find System.Collection.Specialized.OrderedDictionary. Ok it's a dictionaly, collection of key-value-pairs and I have access over index. BUT: Nothing about the kind of implementation. So I have no idea, for what best to use this collection. Is for example myOrderedDictonary[myKey] fast or sequential slow? Do I need hash for my keys or do I not? So it's not possible to make good decicions to use this collection in the right place. Thank you for any help. Hi Rolf,
As for the "OrderedDictionary" collection class you mentioned, it is a new collection involved in .net framework 2.0. Like a normal IDictionary based collection, you can access entry in it through key e.g. myOrderedDictionary[key] or if you known a certain entry's ordered index, you can also use index to locate the entry, e.g. myOrderedDictionary[index] Actually, both of the two access approach are quick and efficient because OrderedDictionary has maintained two collection internally( one is a hashTable and another is a ArrayList). Here is the disassembled code from reflector: ================= [Serializable] public class OrderedDictionary : IOrderedDictionary, IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback { .................... private ArrayList _objectsArray; private Hashtable _objectsTable; .............. public void Add(object key, object value) { if (this._readOnly) { throw new NotSupportedException(SR.GetString("OrderedDictionary_ReadOnly")); } this.objectsTable.Add(key, value); this.objectsArray.Add(new DictionaryEntry(key, value)); } .................... ================== Therefore, whenever you add a new entry(key,value pair) into it, it will add the entry's reference into both the internal hashtable and ArrayList. Thus, it is efficient when you use either key or index to access items in the OrderedDictionary. You can also measure performance based on the hashTable and ArrayList's item accessing. Hope this helps. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hi Rolf,
Does the information in my last reply helps some? If you have any further questions, please feel free to let me know. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
thank you for your help. It works fine. Thank you again and best regards Rolf Welskes Show quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> schrieb im Newsbeitrag news:JDBB8MzeHHA.5272@TK2MSFTNGHUB02.phx.gbl... > Hi Rolf, > > Does the information in my last reply helps some? If you have any further > questions, please feel free to let me know. > > Sincerely, > > Steven Cheng > > Microsoft MSDN Online Support Lead > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > |
|||||||||||||||||||||||