01-14-2008, 02:20 AM
You have to iterate over the keys.
If you have a good guess at where to start iterating, you can save iterations on the front end. Since you know when to end, you can stop iterating early.
The problem is that you are using keys in a situation where you don't know the keys when it comes time to using the data.
Keys are used when you plan on looking up the data when you know the key. This isn't how you are using the data. This isn't the data structure you should be using.
I question if this will actually work in practice since there is the logical possibility of two values having the same key. Picking the right isotopes, two elements could have the same molecular weight.
If you have a good guess at where to start iterating, you can save iterations on the front end. Since you know when to end, you can stop iterating early.
The problem is that you are using keys in a situation where you don't know the keys when it comes time to using the data.
Keys are used when you plan on looking up the data when you know the key. This isn't how you are using the data. This isn't the data structure you should be using.
I question if this will actually work in practice since there is the logical possibility of two values having the same key. Picking the right isotopes, two elements could have the same molecular weight.