CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Hashtable implementation question

  1. #1
    Join Date
    May 2010

    Hashtable implementation question

    Currently I'm implementing hashtable with open addressing(linear probing) and everything seems good(the performance is satisfying) but I have requirement to implement methods for getting all the keys/values. Its ok but the problem is that the requirement is to get the next key/value in O(1) (not amortized)
    How is this possible? Should I implement some other view of the hashtable or what?
    I'm using java as a language if this could be of any help.

  2. #2
    Join Date
    Oct 2006

    Re: Hashtable implementation question

    If you do not need to return all key/value pairs in a sorted order, think about this:
    What if each key/value pair was also a node in a doubly linked list ?


  3. #3
    Join Date
    May 2010

    Re: Hashtable implementation question

    Wow thats it! I don't need them in sorted order so this idea will surely work.
    Thanks man

    The funny thing is that i thought of the idea with the list too but I was thinking for a plain linked list - I'm so stupid sometimes!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)