Re: 2D lookup table



On 31 Sty, 18:16, "Mize-ze" <zahy.bn...@xxxxxxxxx> wrote:
If I want to store and fetch information from a matrix like structure
where the indexes of the matrix are not integers but other data
structures, how such thing can be done without a translation table?

Example:

If I have a list of doubles and I want to store a value per each pairs
of values
What is the best way to do this?

Thanks

I recommend trying jakarta commons collections library.
There is a MultiKey class which you may find useful.
Also remember taht simplest solutions are always the best and hardest
to find.
Map of maps is a little bit complicated solution. You can achieve this
using MultiKey
From API :
Example usage:

// populate map with data mapping key+locale to localizedText
Map map = new HashMap();
MultiKey multiKey = new MultiKey(key, locale);
map.put(multiKey, localizedText);

// later retireve the localized text
MultiKey multiKey = new MultiKey(key, locale);
String localizedText = (String) map.get(multiKey);

I think also that using tranlation table and using bigger table will
be faster than working on maps (it also depends how many objects you
want to store).
If you make some way to translate indexes from int to your own value
it would be simple and fast.

Good luck in finding the solution.
Arthur

.