Guava Table接口
来源:互联网 发布:淘宝全新店铺购买 编辑:程序博客网 时间:2024/05/21 14:02
http://www.yiibai.com/guava/guava_table.html
import java.util.Map;import java.util.Set;import com.google.common.collect.HashBasedTable;import com.google.common.collect.Table;public class GuavaTester { public static void main(String args[]){ //Table<R,C,V> == Map<R,Map<C,V>> /* * Company: IBM, Microsoft, TCS * IBM -> {101:Mahesh, 102:Ramesh, 103:Suresh} * Microsoft -> {101:Sohan, 102:Mohan, 103:Rohan } * TCS -> {101:Ram, 102: Shyam, 103: Sunil } * * */ //create a table Table<String, String, String> employeeTable = HashBasedTable.create(); //initialize the table with employee details employeeTable.put("IBM", "101","Mahesh"); employeeTable.put("IBM", "102","Ramesh"); employeeTable.put("IBM", "103","Suresh"); employeeTable.put("Microsoft", "111","Sohan"); employeeTable.put("Microsoft", "112","Mohan"); employeeTable.put("Microsoft", "113","Rohan"); employeeTable.put("TCS", "121","Ram"); employeeTable.put("TCS", "122","Shyam"); employeeTable.put("TCS", "123","Sunil"); //get Map corresponding to IBM Map<String,String> ibmEmployees = employeeTable.row("IBM"); System.out.println("List of IBM Employees"); for(Map.Entry<String, String> entry : ibmEmployees.entrySet()){ System.out.println("Emp Id: " + entry.getKey() + ", Name: " + entry.getValue()); } //get all the unique keys of the table Set<String> employers = employeeTable.rowKeySet(); System.out.print("Employers: "); for(String employer: employers){ System.out.print(employer + " "); } System.out.println(); //get a Map corresponding to 102 Map<String,String> EmployerMap = employeeTable.column("102"); for(Map.Entry<String, String> entry : EmployerMap.entrySet()){ System.out.println("Employer: " + entry.getKey() + ", Name: " + entry.getValue()); } }}
阅读全文
0 0
- Guava Table接口
- Google Guava学习(8)-Guava集合工具 Table接口
- Guava ---- Table矩阵
- Java-类库-Guava-Table
- Guava collections -- Table
- guava之Table
- Guava使用之Table
- guava之Table
- Google Guava学习之Table
- Guava Table<R,C,V>
- Guava之二维矩阵Table
- Guava学习笔记:Guava新集合-Table等
- Guava学习笔记【10】:Guava新集合-Table等
- Guava-base接口|Ascii|CharMatcher
- Guava Cache之Cache接口
- Google Guava学习(7)-Guava集合工具 Bimap接口
- guava 集合和函数接口妙用
- RateLimit--使用guava来做接口限流
- segmentProject-summer
- 图像分割—基于图的图像分割(Graph-Based Image Segmentation)
- 前缀和,枚举+递推(Average,HDU 5353)
- Q120:PBRT-V3,“直接光照”积分器(14.3章节)
- Intellij IDEA基于Springboot的远程调试
- Guava Table接口
- nginx问题知识汇总
- 怎么申请苹果iOS开发者账号?ios开发者账号申请流程介绍
- Spring_02_Bean基本配置
- python3 网络爬虫(四)如何查找以及使用cookies
- 详解java动态代理模式
- js日期计算
- 浏览器兼容问题
- 实时监控文本框中的数据变化(完美解决方案)