I am planning to use table guava for a 3D hash map implementation. I downloaded that and I am able to import the files. My requirement is the below
I have the below file in my hand and I just have to aggregate the file accordingly and that is shown in the next step.
A100|B100|3
A100|C100|2
A100|B100|5
The aggregation part would be below
A100|B100|8
A100|C100|2
I tried using the below
Table<String,String,Integer> twoDimensionalFileMap= new HashBasedTable<String,String,Integer>();
But this throws me an error, I just want to know two things
HashBasedTable<String,String,Integer>()
map.put(key,value)
. In the similar sense could you guys tell me how to insert the values for this table?Guava contributor here.
HashBasedTable.create()
factory method. (With no arguments, or with expectedRows
and expectedCellsPerRow
.)table.put("A100", "B100", 5)
, just like a Map
except with two keys.From documentation:
Interface Table
Type Parameters:
R - the type of the table row keys C - the type of the table column keys V - the type of the mapped values
Your declaration is right. In order to use it, should be easy as:
Table<String,String,Integer> table = HashBasedTable.create();
table.put("r1","c1",20);
System.out.println(table.get("r1","c1"));
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