Multiple values for the same key HashMap in .NET (C#)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sean

    Multiple values for the same key HashMap in .NET (C#)

    Hi all,

    I have problem finding the .NET equivalent of HashMap in
    C++ STL.

    I CANNOT use Hashtable because I want (there will be more
    than one objects for the same key) objects with the same
    key to be hashed into the same bucket and end up with all
    the objects with the same key being in the same group.

    Thank you very much in advance.



    regards,
    Sean
  • Jon Skeet [C# MVP]

    #2
    Re: Multiple values for the same key HashMap in .NET (C#)

    Sean <anonymous@disc ussions.microso ft.com> wrote:[color=blue]
    > I have problem finding the .NET equivalent of HashMap in
    > C++ STL.
    >
    > I CANNOT use Hashtable because I want (there will be more
    > than one objects for the same key) objects with the same
    > key to be hashed into the same bucket and end up with all
    > the objects with the same key being in the same group.
    >
    > Thank you very much in advance.[/color]

    If you want more than one object for the same key, you can make each
    Hashtable entry an ArrayList which you add new entries to. It should be
    fairly easy to encapsulate that behaviour if you want to.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...