can we get away with "Arraylist" rather than using hashtable datastructure...?
thank you
Printable View
can we get away with "Arraylist" rather than using hashtable datastructure...?
thank you
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.
Interesting, why shouldn't one use a hashtable? Guess I've been doing something wrong and didn't know it.
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.
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.
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 ip:port 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