• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bi-directional Map  RSS feed

 
Biju Nair
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Please help me in solving this problem

I have a map which stores a key pair value. key is a integer and the corresponding value is an array of strings. I want to implement a bi-directional map in such a way that if I pass any one value in an array, it should return me the corresponding integer value.

If someone can provide some sample code, please do..

I have tried the BidiMap in apache commons-collections, but didn't help

Thanx n Regards
Biju Nair
 
Stefan Krompass
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the simplest idea is to use a second Map which stores the elements of the String-arrays as keys (assuming a String cannot appear twice) and the Integers as values.

Stefan
[ December 09, 2004: Message edited by: Stefan Krompass ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!