• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to strore duplicate key data in java  RSS feed

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
I just want to know is there any data structre proivide by java in which I can store given dada
I can't use any class of MAP interface because it always ask for unique keys. so please sugest me how to store t his type of data

Data has to store

1100 JAVA
1200 J2EE
1300 JAVA,J2EE
1100 JAVA,J2EE,J2ME
1200 TOMCAT,J2EE,J2ME
1400 WEBSERVER,TOMCAT
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would a simple Set of little objects work for you?

You could put the same code into many different items and put them all in the set. To find all the descriptions that match code iterate the set and look for code matches.

There is much fun to be had here. Add a constructor with code & description parameters to make creating these a little easier. Change the variables to private and add getters (no setters) to make nice immutable items. Add a compareTo method and put these into an ordered set or list ... could that speed up searching?

Any of that help?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot something I've actually used many times ... a map of lists. This is not quite Java but I hope you can see the idea ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!