GS Collections v7.0.3 Release Notes

Release Date: 2016-03-16 // about 8 years ago
  • ๐Ÿ› Bug Fixes

    • ๐Ÿ›  Fixed memory leak in HashBiMap.
    • ๐Ÿ›  Fixed incorrect code path in key collision handling and keyset iterator based remove operation in primitive Maps with Hashing Strategy.

    Acquiring Eclipse Collections


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


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


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

Previous changes from v7.0.0

  • Acquiring GS Collections


    \<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\>


    \<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"/\>

    ๐Ÿ’ฅ Breaking Changes

    • ๐Ÿšš MutableCollection.removeIf() now returns boolean.
    • Sorted sets, bags, and maps implement ReversibleIterable. Added OrderedMap interface to represent a linked hash map.
    • Overrode BiMap.partition() to return PartitionUnsortedSet.
    • UnifiedMap and UnifiedSet now throw if constructed with a load factor greater than 1.
    • toStringOfItemToCount() in ImmutableEmptyBag now consistent with other Bags.
      Returns "{}" instead of ""

    ๐Ÿ†• New Functionality

    Primitive Collections

    ๐Ÿ›  <Primitive>List.binarySearch() Fixes #20


    Similar to ObjectPrimitiveHashMap but uses a HashingStrategy to hash and compare keys. Analogous to UnifiedMapWithHashingStrategy.


    ๐Ÿ”€ Behaves exactly same as <Primitive>Iterable.forEach(). Added to be in sync with RichIterable.each(Procedure) that was introduced in 6.0 to avoid ambiguity conflict with Iterable.forEach(Consumer).


    aggregateInPlaceBy(), aggregateBy(), zip(), zipWithIndex(), partition(), selectInstancesOf(), collectIf(), groupBy(), and groupByEach() on MutablePrimitiveObjectMap

    ๐Ÿ‘‰ Use the Kahan summation algorithm on sum() and sumBy() methods on primitive collections

    Other new Functionality

    CharAdapter, CodePointAdapter and CodePointList

    • CharAdapter implements CharSequence and ImmutableCharList, and it represents String as a collection of char values.
    • CharPointAdapter implements CharSequence and ImmutableIntList. It behaves similarly to CharAdapter but it represents String as the unicode codepoint values that are ints.
    • CharPointList is similar to CharPointAdapter but it calculates and caches the unicode code point values as an ImmutableIntList internally.

      CharAdapter chars = CharAdapter.adapt("This is an example");CodePointAdapter codePoints = CodePointAdapter.adapt("Can you read this Kanji \"\uD840\uDC00\"? I cannot.");CodePointList codePointList = CodePointList.from("BMP stands for Basic Multilingual Pane. \"\uD840\uDC00\" is a unicode character outside BMP.");System.out.println("Upper case: " + chars.collectChar(Character::toUpperCase));System.out.println("Unicode character outside Basic Multilingual Pane: " + codePoints.reject(Character::isBmpCodePoint).distinct());System.out.println("English only: " + codePointList.reject(Character::isIdeographic));

    ๐Ÿ–จ Prints

    Upper case: THIS IS AN EXAMPLE
    Unicode character outside Basic Multilingual Pane: ๐ €€
    English only: BMP stands for Basic Multilingual Pane. "" is a unicode character outside BMP.



    Returns a new ListIterable containing the distinct elements in this list. Conceptually similar to new UnifiedSetWithHashingStrategy(hashingStrategy, listIterable).toList() but retains the original order.

    MutableBagMultimap.putOccurrences(K key, V value, int occurrences)

    โž• Adds occurrences of value to the MutableBag at key in the multimap.

    MutableList.shuffleThis(): MutableList

    Shuffles this list and returns this list. Overload optionally takes a Random.

    Predicates.cast() and Functions.cast()

    ๐Ÿ‘ Allows a Java 8 lambda or method reference to be used in a method taking a predicate or a function without requiring a cast. The methods can be used in places where two or more method overloads could apply when used with a lambda or method reference.

    Lists.mutable.of(1, 2, null).removeIf(each -\> each == null);

    This code fails to compile with the following error.

    Error: java: reference to removeIf is ambiguous both method removeIf(java.util.function.Predicate\<? super E\>) in java.util.Collection and method removeIf(\<? super T\>) in match

    โ†ช You can work around the problem by using a cast or the method Predicates.cast().

    Lists.mutable.of(1, 2, null).removeIf(Predicates.cast(each -\> each == null));

    โž• Add factory method for creating mutable sets and maps of a given initial capacity.

    For example: Sets.mutable.withInitialCapacity(100)

    ๐ŸŽ Optimizations and Performance Tests

    • โšก๏ธ Optimize FastList.addAll() and UnifiedSet.addAll() for RandomAccess lists.
    • โšก๏ธ Optimize UnifiedMap's short-circuit methods to not delegate to an iterator.
    • ๐Ÿ”จ Refactor ImmutableSortedBag.newWith() and newWithout() to take O(n) time.
    • โž• Add JDK 8 Streams based JMH tests for FastList.
    • โž• Add JMH Tests for HashMap<Integer, Integer>

    ๐Ÿ› Bug Fixes

    • ๐Ÿ›  Fix bug in CollectIterable.toArray() where it returns T[] instead of Object[].
    • ๐Ÿ›  Fix iterator's remove() method in ObjectPrimitiveHashMap so that it doesn't rehash.
    • ๐Ÿ›  Fix code point iteration in StringIterate and provide CharAdapter and CodePointList as OO alternatives for string iteration.

    ๐Ÿ“š Documentation and Deprecation

    • โž• Add information about required Java versions to Fixes #18.
    • โœจ Enhance Javadoc of Iterate.
    • โšก๏ธ Update Javadoc in InternalIterable and RichIterable to include Java 8 lambda examples.
    • ๐Ÿ—„ Deprecate ArrayIterate.sort() and recommend direct calls to Arrays.sort().
    • ๐Ÿ—„ Deprecate overloaded methods in StringIterate and add specialization alternatives that work better with Java 8 lambdas.