Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2007

Tip: Looking for answers? Try searching our database.

What is System.Collection.Specialized.OrderedDictionary - .net 2.0 msdn

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rolf Welskes - 04 Apr 2007 16:41 GMT
Hello,
in .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.
Steven Cheng[MSFT] - 05 Apr 2007 04:26 GMT
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.
Steven Cheng[MSFT] - 10 Apr 2007 06:43 GMT
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.
Rolf Welskes - 11 Apr 2007 14:39 GMT
Hello,
thank you for your help.
It works fine.
Thank you again and best regards
Rolf Welskes

> Hi Rolf,
>
[quoted text clipped - 9 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.