Results 1 to 6 of 6

Thread: do we need "Hashtable" datastructure...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    do we need "Hashtable" datastructure...

    can we get away with "Arraylist" rather than using hashtable datastructure...?

    thank you

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    All objects from the collection family use hashtables as their base. Your advised to use one of these (arraylist, sortedlist, queue etc etc) instead of using the hashtable directly anyway, so yes, is the answer. Make sure to lookup all the various collection objects, as they differ in use, its in the help file.

  3. #3
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Interesting, why shouldn't one use a hashtable? Guess I've been doing something wrong and didn't know it.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No there is nothing wrong with using the Hashtable directly in fact sometimes it can be good since it has a smaller footprint than the rest.

  5. #5
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    You can obviously do whats needed to get the job done, its just a M$ best practice. Often you need something else (like sorting, using keys) as well as just a bucket to hold your objects in.

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    ok - please let me know if there's a better way than a hashtable for the following.

    I have a service that accepts multiple tcp requests from clients, then forwards them on to a server. When a response comes back from that server, I need to know which client originally made the request.

    The client's iport is not in the request or response, but both contain a mnemonic specific to the client.

    So when I get a client's request , I put the mnemonic as the key and the socket object as the value into a hashtable. Then, when the server sends back the response, I look up the socket object based on the mnemonic contained in the message and forward to that client.

    This seems to work fine, but it's brand new, so if there's a better way to go about it, I'd like to know.

    Thanks,
    Mike

Posting Permissions

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



Click Here to Expand Forum to Full Width