I need a data structure that I could store my information in a two dimensional way. For example imagine a table that contains user-item ratings. I need to store all ratings for all users. let's say, user u1. I need to store ratings for user u1 and u2 and u3 and all other users. But the problem is I also need too store all ratings for all items. For example I need to store ratings provided by all users for each item. So I need something like a map that for users the key is the user ID and the value is the set of ratings. I can do that easily. But my problem is how I can also store ratings for Items. for example a map that the key is the item ID and the value is the set of ratings provided be users for that Item. I wanted to upload a table but since I didn't have enough reputation I couldn't do that.So just imagine a table like a two dimensional matrix that rows are users and columns are items. Is there a data structure that can do that? Or I should build two different maps? maybe there is a better option than Map but Since I had to choose a title for my question I wrote map.
Thanks
You can use the Table class from the free Guava library
Table<Integer, String, Double> table = HashBasedTable.create();
table.put(1, "a", 2.0);
double v = table.get(1, "a"); // getting 2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With