Table Interface
Table represents a special map where two keys can be specified in combined fashion to refer to a single value. It is similar to creating a map of maps.
package org.fool.guava.collections; import java.util.Map; import java.util.Set; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; public class TableTest { public static void main(String[] args) { // Table<R,C,V> == Map<R,Map<C,V>> // 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"); ibmEmployees.forEach((id, name) -> System.out.println("Emp Id: " + id + ", Name: " + name)); // get all the unique keys of the table Set<String> employers = employeeTable.rowKeySet(); System.out.print("Employers: "); employers.forEach(employer -> System.out.print(employer + " ")); System.out.println(); //get a Map corresponding to 102 Map<String,String> employerMap = employeeTable.column("102"); employerMap.forEach((id, name) -> System.out.println("Emp Id: " + id + ", Name: " + name)); } }
output
List of IBM Employees Emp Id: 103, Name: Suresh Emp Id: 101, Name: Mahesh Emp Id: 102, Name: Ramesh Employers: IBM TCS Microsoft Emp Id: IBM, Name: Ramesh
相关推荐
guava类似Apache Commons工具集包含了若干被Google的 Java项目广泛依赖 的核心库
赠送jar包:guava-30.0-jre.jar; 赠送原API文档:guava-30.0-jre-javadoc.jar; 赠送源代码:guava-30.0-jre-sources.jar; 赠送Maven依赖信息文件:guava-30.0-jre.pom; 包含翻译后的API文档:guava-30.0-jre-...
赠送jar包:guava-27.0.1-jre.jar; 赠送原API文档:guava-27.0.1-jre-javadoc.jar; 赠送源代码:guava-27.0.1-jre-sources.jar; 赠送Maven依赖信息文件:guava-27.0.1-jre.pom; 包含翻译后的API文档:guava-...
赠送jar包:guava-25.0-jre.jar; 赠送原API文档:guava-25.0-jre-javadoc.jar; 赠送源代码:guava-25.0-jre-sources.jar; 赠送Maven依赖信息文件:guava-25.0-jre.pom; 包含翻译后的API文档:guava-25.0-jre-...
### Google Guava Collections 使用介绍 #### 一、概述 Google Guava Collections 是 Java Collections Framework 的一个强大且实用的非官方扩展 API。它由 Google 工程师 Kevin Bourrillion 和 Jared Levy 在著名...
赠送jar包:guava-20.0.jar; 赠送原API文档:guava-20.0-javadoc.jar; 赠送源代码:guava-20.0-sources.jar; 赠送Maven依赖信息文件:guava-20.0.pom; 包含翻译后的API文档:guava-20.0-javadoc-API文档-中文...
guava-27.0-jre.jar
赠送jar包:guava-11.0.2.jar; 赠送原API文档:guava-11.0.2-javadoc.jar; 赠送源代码:guava-11.0.2-sources.jar; 赠送Maven依赖信息文件:guava-11.0.2.pom; 包含翻译后的API文档:guava-11.0.2-javadoc-API...
赠送jar包:guava-29.0-jre.jar; 赠送原API文档:guava-29.0-jre-javadoc.jar; 赠送源代码:guava-29.0-jre-sources.jar; 赠送Maven依赖信息文件:guava-29.0-jre.pom; 包含翻译后的API文档:guava-29.0-jre-...
赠送jar包:guava-28.2-jre.jar; 赠送原API文档:guava-28.2-jre-javadoc.jar; 赠送源代码:guava-28.2-jre-sources.jar; 赠送Maven依赖信息文件:guava-28.2-jre.pom; 包含翻译后的API文档:guava-28.2-jre-...
这个压缩包包含的是Guava库的18.0版本,分为两个部分:`guava-18.0.jar`和`guava-18.0-sources.jar`。 `guava-18.0.jar`是Guava库的编译后的二进制版本,包含了所有Guava类和方法的字节码,开发者可以直接在项目中...
赠送jar包:guava-16.0.1.jar; 赠送原API文档:guava-16.0.1-javadoc.jar; 赠送源代码:guava-16.0.1-sources.jar; 赠送Maven依赖信息文件:guava-16.0.1.pom; 包含翻译后的API文档:guava-16.0.1-javadoc-API...
guava-27.1-jre
最新版 guava-30.1-jre.jar
google-collections-1.0-rc2.jar 的jar包,放心使用。
赠送jar包:guava-27.0.1-jre.jar; 赠送原API文档:guava-27.0.1-jre-javadoc.jar; 赠送源代码:guava-27.0.1-jre-sources.jar; 赠送Maven依赖信息文件:guava-27.0.1-jre.pom; 包含翻译后的API文档:guava-...
赠送jar包:guava-20.0.jar; 赠送原API文档:guava-20.0-javadoc.jar; 赠送源代码:guava-20.0-sources.jar; 赠送Maven依赖信息文件:guava-20.0.pom; 包含翻译后的API文档:guava-20.0-javadoc-API文档-中文...
guava
赠送jar包:guava-18.0.jar; 赠送原API文档:guava-18.0-javadoc.jar; 赠送源代码:guava-18.0-sources.jar; 包含翻译后的API文档:guava-18.0-javadoc-API文档-中文(简体)版.zip 对应Maven信息:groupId:...
赠送jar包:guava-23.0.jar; 赠送原API文档:guava-23.0-javadoc.jar; 赠送源代码:guava-23.0-sources.jar; 赠送Maven依赖信息文件:guava-23.0.pom; 包含翻译后的API文档:guava-23.0-javadoc-API文档-中文...