GS Collections:受Smalltalk启发的集合框架

网友投稿 761 2022-10-23

GS Collections:受Smalltalk启发的集合框架

GS Collections:受Smalltalk启发的集合框架

GS Collections is now Eclipse Collections

We are pleased to announce that GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections.

Eclipse Collections 7.0 has the exact same feature set as GS Collections 7.0.

Going forward, any new features will be developed in Eclipse Collections. We will only port critical bug fixes to GS Collections. To support smooth migration for users, we implemented a conversion application gsc-ec-converter. Please plan your migration accordingly from GS Collections to Eclipse Collections.

GS Collections

GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map implementations with a rich API and set of utility classes that work with any JDK compatible Collections, Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework. The library modules in GS Collections are compatible with Java 5 (gs-collections-api, gs-collections, and gs-collections-testutils).

Quick Example

GS Collections puts iteration methods on the container types. Lambdas are simulated using anonymous inner classes. Here's a code example that demonstrates the usual style of programming with GS Collections.

MutableList people = FastList.newListWith(person1, person2, person3);MutableList sortedLastNames = people.collect(Person.TO_LAST_NAME).sortThis();System.out.println("Comma separated, sorted last names: " + sortedLastNames.makeString());

Person.TO_LAST_NAME is defined as a constant Function in the Person class.

public static final Function TO_LAST_NAME = new Function(){ public String valueOf(Person person) { return person.lastName; }};

In Java 8, the Function can be replaced with a lambda:

MutableList sortedLastNames = people.collect(person -> person.getLastName()).sortThis();

Or, a method reference:

MutableList sortedLastNames = people.collect(Person::getLastName).sortThis();

Why GS Collections?

Improves readability and reduces duplication of iteration code (enforces DRY/OAOO)Implements several, high-level iteration patterns (select, reject, collect, inject into, etc.) on "humane" container interfaces which are extensions of the JDK interfacesProvides a consistent mechanism for iterating over Collections, Arrays, Maps, and StringsProvides replacements for ArrayList, HashSet, and HashMap optimized for performance and memory usagePerforms more "behind-the-scene" optimizations in utility classesEncapsulates a lot of the structural complexity of parallel iteration and lazy evaluationAdds new containers including Bag, Interval, Multimap, BiMap, and immutable versions of all typesHas been under active development since 2005 and is a mature library

Documentation

The best way to learn about GS Collections is to dive into the code kata. The kata is a fun way to learn idiomatic GS Collections usage and hone your skills through practice. Please refer to the wiki for more details.

For more comprehensive documentation, take a look at the Reference Guide.

Contributions

We currently do all development in an internal Subversion repository and are not prepared to take external contributions. However, we watch the issue tracker for bug reports and feature requests.

FAQ

Why is Goldman Sachs open-sourcing GS Collections?

We believe that GS Collections offers a significant advantage over existing solutions. We hope others will benefit from it.We believe in the power of the technical community to help improve GS Collections.Technology is a huge part of what we do at Goldman Sachs. GS Collections exemplifies our commitment to technology.We use open source software in many of our operations. We have benefited from the work of others and we'd like to give something back.

Does Goldman Sachs use GS Collections?

Yes, we use GS Collections in many of our internal applications.

Acquiring GS Collections

Download

Version 7.0.0Older versions

Maven

com.goldmansachs gs-collections-api 7.0.0 com.goldmansachs gs-collections 7.0.0 com.goldmansachs gs-collections-testutils 7.0.0 test com.goldmansachs gs-collections-forkjoin 7.0.0

Gradle

compile 'com.goldmansachs:gs-collections-api:7.0.0'compile 'com.goldmansachs:gs-collections:7.0.0'testCompile 'com.goldmansachs:gs-collections-testutils:7.0.0'compile 'com.goldmansachs:gs-collections-forkjoin:7.0.0'

Ivy

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:领域驱动设计系列关键概念
下一篇:判断MySQL记录是否存在方法比较
相关文章

 发表评论

暂时没有评论,来抢沙发吧~