SCJP, SCJD(In Progress)<br /> <br />"They whom make no mistakes usually make nothing at all."
SCJP, SCJD(In Progress)<br /> <br />"They whom make no mistakes usually make nothing at all."
SCJP, SCJD(In Progress)<br /> <br />"They whom make no mistakes usually make nothing at all."
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
SCJP, SCJD(In Progress)<br /> <br />"They whom make no mistakes usually make nothing at all."
Originally posted by Joe Quickshot:
Thanks for the code. You are correct, this is for work and not homework. However, I am seeing that the code requires Java 5.0. I think I can work with it to make it work with 1.4.2, and post my results. Thanks again for the head start.
![]()
Originally posted by Peter Chase:
I admit I didn't read the previous posts in detail, so this might not be helpful, but...
Couldn't you use a SortedMap? An implementation is provided: TreeMap. This will keep itself sorted, as you add entries.
Also, if you do want a map with two-way look-up, you can simply use two parallel maps. One maps keys to values and the other maps values to keys. I have sometimes made a wrapper class, TwoWayMap, to encapsulate this idea.
You talk about using Hashtable and Vector. It sounds like this is new code, and you're using Java 1.4. Therefore, you should not be using these old classes, but instead should use HashMap and ArrayList, or similar. The synchronisation provided by Hashtable and Vector is rarely useful, because it's on an operation-by-operation level; it justs wastes performance.
Originally posted by Joe Quickshot:
I guess I chose Vector since I can start with the initial size of 10 and then do .addElement() and it increases the size by one. I do this because the total capacity could be 1 or 100, never more than 1000. I don't want to reserve 100 arrays with 1000 entries to ensure capacity. I wouldn't be surprised if I am missing something though.
I do like the idea of the wrapper class with two maps. I haven't had much time to work on this today, but will keep plugging away.
Thanks always,
Joe
Straws are for suckers. Now suck on this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|