gs-collections


Source link: https://github.com/goldmansachs/gs-collections

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<Person> people = FastList.newListWith(person1, person2, person3);
 MutableList<String> 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<Person, String> TO_LAST_NAME = new Function<Person, String>() {

  public String valueOf(Person person)
  {

return person.lastName;
  
}
 
}
; 

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

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

Or, a method reference:

MutableList<String> 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 interfaces
  • Provides a consistent mechanism for iterating over Collections, Arrays, Maps, and Strings
  • Provides replacements for ArrayList, HashSet, and HashMap optimized for performance and memory usage
  • Performs more "behind-the-scene" optimizations in utility classes
  • Encapsulates a lot of the structural complexity of parallel iteration and lazy evaluation
  • Adds new containers including Bag, Interval, Multimap, BiMap, and immutable versions of all types
  • Has 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

Maven

<dependency>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections-api</artifactId>
<version>7.0.0</version> </dependency>  <dependency>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections</artifactId>
<version>7.0.0</version> </dependency>  <dependency>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections-testutils</artifactId>
<version>7.0.0</version>
<scope>test</scope> </dependency>  <dependency>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections-forkjoin</artifactId>
<version>7.0.0</version> </dependency>

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

<dependency org="com.goldmansachs" name="gs-collections-api" rev="7.0.0" /> <dependency org="com.goldmansachs" name="gs-collections" rev="7.0.0" /> <dependency org="com.goldmansachs" name="gs-collections-testutils" rev="7.0.0" /> <dependency org="com.goldmansachs" name="gs-collections-forkjoin" rev="7.0.0"/>

Resources

The library allows to format user input on the fly according to the provided mask and to extract valueable characters.

Provides a simple way to extend the default RecyclerView behaviour with support for headers, footers, empty view, DiffUtil and ArrayAdapter like methods.

Simple and pretty, powerful and flexible logger for android and java, can concurrently print the log to multiple target like Logcat, System.out and File, or even Server (or anywhere) if you like.

An Animator operation set. You can use it to handle several Property Animations.

A TextView that can get word in it's content by click, and you can set HighlightText also.

A layout that implemented ripple effect for transition animation.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes