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.