Home > Archive > Java Help > October 2004 > Two dimensional hash
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Two dimensional hash
|
|
| Hongyu Zhang 2004-10-28, 8:57 pm |
| Dear all,
Anyone knows an easy way to use a two dimensional hash in Java? For
example, in Perl, it can be used like $foo{$bar1}{$bar2}.
Thanks!
| |
|
|
| Thomas Weidenfeller 2004-10-29, 8:57 am |
| Hongyu Zhang wrote:
> Dear all,
>
> Anyone knows an easy way to use a two dimensional hash in Java?
Yes, the obvious ones:
* Use Maps of Maps - inefficient
or
* Combine the two keys into one object, using that as a key in a Map.
Which is the way multidimensional hashs are usually implemented.
/Thomas
| |
| Hongyu Zhang 2004-10-29, 8:57 pm |
| Both methods that you suggested are good enough for me. Thanks very much, Thomas!
Thomas Weidenfeller <nobody@ericsson.invalid> wrote in message news:<clsstv$3q6$1@newstree.wise.edt.ericsson.se>...
> Hongyu Zhang wrote:
>
> Yes, the obvious ones:
>
> * Use Maps of Maps - inefficient
>
> or
>
> * Combine the two keys into one object, using that as a key in a Map.
> Which is the way multidimensional hashs are usually implemented.
>
> /Thomas
|
|
|
|
|