之前分享了vavr,今天在分享一个同类框架eclipse-collections 官方文档:http://www.eclipse.org/collections/ <dependency> <groupId 11.0.0</version> </dependency> <dependency> <groupId>org.eclipse.collections</groupId> <artifactId>eclipse-collections .stream() .filter(person -> person.hasPet(PetType.CAT)) .collect(Collectors.toList()); 用eclipse-collections
跟昨天介绍的eclipse-collections一样,这是一个同类产品: 仓库地址:https://github.com/amaembo/streamex JavaDoc:http://amaembo.github.io StreamEx.of(users).groupingBy(User::getRole); StreamEx.of(1,2,3).joining("; "); // "1; 2; 3" 对比起来好像比eclipse-collections
Eclipse 的 Collections 库 其实 Eclipse 基金会也创建一个开源的 Java 集合框架库叫 eclipse-collections。 github 地址:https://github.com/eclipse/eclipse-collections 对 Map 的主要增强如下, 创建和初始化可变与不可变 Map。
关于减少对象体积,这里我给大家推荐一个jar包——eclipse-collections,其中提供了好多原始类型的集合,比如IntMap、LongMap…… 使用原始类型(int,long,double ……)而不是封装类型(Integer,Long,Double……),在一些数值偏多的业务中很有优势,如下图是我对比了HashSet<Integer>和eclipse-collections中IntSet