• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with Data Structures...

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am unable to decide as to which data structure to use for the following purpose
Slno Name
01 abc
01 def
02 abc
03 xyz

I want these to be grouped and then stored accordingly Like: 01 {abc,def}
02 {abc}
03 {xyz}
I want to group these as itemsets based on the sl no value.

Please Help Thanks in advance.
 
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you mean which collection class
 
Sneha Kashyap
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Yeah and how to use it to achieve the same.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about Map<Integer, List<String>>?

Or maybe Map<String, List<String>> if the "01" is a string and not an integer.
 
Sneha Kashyap
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but map cannot contain duplicate values, I need to have duplicate keys, like 01 mapping to abc,def Can you help me as to how this can be achieved.
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i guess it is TreeSet which will eliminate the duplicate not the HashMap.
name-value pairs are sufficient.
don't confuse with HashSet and HashMap.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks, but map cannot contain duplicate values, I need to have duplicate keys, like 01 mapping to abc,def


That's not duplicate keys in the Map, that's multiple entries in the List.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sneha Kashyap wrote: Thanks, but map cannot contain duplicate values, I need to have duplicate keys, like 01 mapping to abc,def Can you help me as to how this can be achieved.

Ulf has already told you what to do.
 
reply
    Bookmark Topic Watch Topic
  • New Topic