GS Collections v7.0.3 Release Notes
Release Date: 2016-03-16 // about 7 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
Maven
\<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\>
Gradle
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'
Ivy
\<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
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\>
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"/\>
๐ฅ Breaking Changes
- ๐
MutableCollection.removeIf()
now returnsboolean
. - Sorted sets, bags, and maps implement
ReversibleIterable
. AddedOrderedMap
interface to represent a linked hash map. - Overrode
BiMap.partition()
to returnPartitionUnsortedSet
. UnifiedMap
andUnifiedSet
now throw if constructed with a load factor greater than 1.toStringOfItemToCount()
inImmutableEmptyBag
now consistent with other Bags.
Returns"{}"
instead of""
๐ New Functionality
Primitive Collections
๐
<Primitive>List.binarySearch()
Fixes #20ObjectPrimitiveHashMapWithHashingStrategy
Similar to
ObjectPrimitiveHashMap
but uses aHashingStrategy
to hash and compare keys. Analogous toUnifiedMapWithHashingStrategy
.<Primitive>Iterable.each()
๐ Behaves exactly same as
<Primitive>Iterable.forEach()
. Added to be in sync withRichIterable.each(Procedure)
that was introduced in 6.0 to avoid ambiguity conflict withIterable.forEach(Consumer)
.Lazy<Primitive>Iterable.collect<Primitive>()
aggregateInPlaceBy()
,aggregateBy()
,zip()
,zipWithIndex()
,partition()
,selectInstancesOf()
,collectIf()
,groupBy()
, andgroupByEach()
onMutablePrimitiveObjectMap
๐ Use the Kahan summation algorithm on
sum()
andsumBy()
methods on primitive collectionsOther new Functionality
CharAdapter
,CodePointAdapter
andCodePointList
CharAdapter
implementsCharSequence
andImmutableCharList
, and it represents String as a collection of char values.CharPointAdapter
implementsCharSequence
andImmutableIntList
. It behaves similarly toCharAdapter
but it represents String as the unicode codepoint values that are ints.CharPointList
is similar toCharPointAdapter
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.
ImmutableSortedBag
ListIterable.distinct(HashingStrategy)
Returns a new
ListIterable
containing the distinct elements in this list. Conceptually similar tonew UnifiedSetWithHashingStrategy(hashingStrategy, listIterable).toList()
but retains the original order.MutableBagMultimap.putOccurrences(K key, V value, int occurrences)
โ Adds
occurrences
ofvalue
to theMutableBag
atkey
in the multimap.MutableList.shuffleThis(): MutableList
Shuffles this list and returns this list. Overload optionally takes a
Random
.Predicates.cast()
andFunctions.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(com.gs.collections.api.block.predicate.Predicate\<? super T\>) in com.gs.collections.api.collection.MutableCollection 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()
andUnifiedSet.addAll()
forRandomAccess
lists. - โก๏ธ Optimize
UnifiedMap
's short-circuit methods to not delegate to an iterator. - ๐จ Refactor
ImmutableSortedBag.newWith()
andnewWithout()
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 returnsT[]
instead ofObject[]
. - ๐ Fix iterator's
remove()
method inObjectPrimitiveHashMap
so that it doesn't rehash. - ๐ Fix code point iteration in
StringIterate
and provideCharAdapter
andCodePointList
as OO alternatives for string iteration.
๐ Documentation and Deprecation
- โ Add information about required Java versions to
README.md
. Fixes #18. - โจ Enhance Javadoc of
Iterate
. - โก๏ธ Update Javadoc in
InternalIterable
andRichIterable
to include Java 8 lambda examples. - ๐ Deprecate
ArrayIterate.sort()
and recommend direct calls toArrays.sort()
. - ๐ Deprecate overloaded methods in
StringIterate
and add specialization alternatives that work better with Java 8 lambdas.
- ๐