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 / January 2005

Tip: Looking for answers? Try searching our database.

MultiSets in the Framework

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cairn - 01 Jan 2005 15:37 GMT
What is the equiverlant of a C++ STL MultiSet in the Framework, as I wish to
register a number of objects with the same Key. The IDictionary class only
seem to support one instance be Key.

Thanks in Advance.
Chris Taylor - 01 Jan 2005 16:10 GMT
Hi,

Unfortunately there is no corresponding collection in .NET Framework for
std::multiset. Depending on your requirements you might consider using the
Hashtable and storing an ArrayList associated with the key you are adding.
Then if the key already exists add the value to the ArrayList.

The following untested/uncompiled code should give you an idea of what I
mean.

private Hashtable _hash = new Hashtable();
public void Add(object key, object value)
{
 ArrayList list = (ArrayList)_hash[key];
 if (list == null)
 {
   list = new ArrayList();
   hash[key] = list;
 }
 list.Add(value);
}

Hope this helps
Signature

Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor

> What is the equiverlant of a C++ STL MultiSet in the Framework, as I wish to
> register a number of objects with the same Key. The IDictionary class only
> seem to support one instance be Key.
>
> Thanks in Advance.

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.