Nan*_*mar 5 java hash hashmap guava
我打算使用表guava进行3D哈希映射实现.我下载了,我可以导入文件.我的要求如下
我手中有下面的文件,我只需要相应地聚合文件,这将在下一步中显示.
A100|B100|3
A100|C100|2
A100|B100|5
Run Code Online (Sandbox Code Playgroud)
聚合部分将在下面
A100|B100|8
A100|C100|2
Run Code Online (Sandbox Code Playgroud)
我尝试使用下面的内容
Table<String,String,Integer> twoDimensionalFileMap= new HashBasedTable<String,String,Integer>();
Run Code Online (Sandbox Code Playgroud)
但这让我错了,我只想知道两件事
HashBasedTable<String,String,Integer>()map.put(key,value).在类似的意义上,你们可以告诉我如何插入这个表的值?Lou*_*man 27
番石榴贡献者在这里.
HashBasedTable.create()工厂方法.(没有参数,或者expectedRows和expectedCellsPerRow.)table.put("A100", "B100", 5),就像Map使用两个键的除外.来自文档:
接口表
类型参数:
Run Code Online (Sandbox Code Playgroud)R - the type of the table row keys C - the type of the table column keys V - the type of the mapped values
你的声明是对的.为了使用它,应该很容易:
Table<String,String,Integer> table = HashBasedTable.create();
table.put("r1","c1",20);
System.out.println(table.get("r1","c1"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20155 次 |
| 最近记录: |