Eclipse Collections 11.0 Released

Donald Raab
7 min readNov 29, 2021

--

Features you want with the collections you need.

Eclipse Collections Logo

Eclipse Collections 11.0 is here!

Eclipse Collections 11.0 in Maven Central

I’m excited to share that the Eclipse Collections 11.0 release is now available in Maven Central. It has been over a year since we released Eclipse Collections 10.4 in August, 2020. Since then there have been three new JDK releases (15, 16, 17)! Eclipse Collections continues to participate in the OpenJDK Quality Outreach Program and tests against the latest releases of the JDK as they become available. We are currently building and testing actively against JDK 8, 11, 17, and 18 EA.

Release announcement on Twitter from Sirisha Pratha

10 years as OSS, 6 years at Eclipse Foundation

GS Collections was released in January 2012, and was migrated to the Eclipse Foundation in December 2015. We celebrate 6 years of Eclipse Collections at the Eclipse Foundation in December 2021, and 10 years of open source development and public releases in January 2022.

Thank you to everyone who worked to make Eclipse Collections possible, and to all of the contributors who have invested time and energy into this wonderfully feature rich library the past 6 years at the Eclipse Foundation.

Here’s a look back at the article in InfoQ detailing GS Collections migrating to the Eclipse Foundation to become Eclipse Collections six years ago.

Thank you to the release team

The Eclipse Collections 11.0 release would not have been possible without the efforts of Eclipse Collections committer Sirisha Pratha and Eclipse Collections Project Lead Nikhil Nanivadekar. Thank you for all of your hard work at delivering this release!

Thank you to the community

The 11.0 release has a lot of new features submitted by our outstanding community of contributors. Thank you so much to all of the contributors who donated their valuable time to making Eclipse Collections more feature rich and even higher quality. Your efforts are very much appreciated.

New Features with Contributor Blogs

I’ve been encouraging Eclipse Collections contributors to write blogs about the features they contribute to the project. I do my best to set a good example and try to regularly blog about any features I added to Eclipse Collections, or new katas I add to the Eclipse Collections Kata repository.

Following are a few of the blogs written by contributors about features they have contributed to the Eclipse Collections 11.0 release.

  • Added anySatisfyWithOccurrences, allSatisfyWithOccurrences, noneSatisfyWithOccurrences, detectWithOccurrences to Bag.

Blog by Alex Goldberg

  • Added putAllMapIterable method to MutableMap.
  • Added withMapIterable to MutableMap.
  • Added newWithMap and newWithMapIterable to ImmutableMap.

Blog by Neha Sardana

  • Added toImmutableList/Set/Bag/Map/BiMap to RichIterable.
  • Added toImmutableSortedList/Set/Bag to RichIterable.
  • Added toImmutableSortedBag/List/Set with Comparator to RichIterable.
  • Added toImmutableSortedBagBy/ListBy/SetBy with Function to RichIterable.

Blog by Donald Raab

  • Added ClassComparer utility.

Blog by Donald Raab

More new Features w/ Examples

The following are the remaining list of new features. The features in bold have examples immediately following.

  • Added selectWithIndex and rejectWithIndex to OrderedIterable and ListIterable.
@Test
public void selectWithIndex()
{
var list = Lists.mutable.with(1, 2, 3, 4);
var actual = list.selectWithIndex((each, i) -> each + i > 3);
var expected = Lists.mutable.with(3, 4);
Assertions.assertEquals(expected, actual);
}

@Test
public void rejectWithIndex()
{
var list = Lists.mutable.with(1, 2, 3, 4);
var actual = list.rejectWithIndex((each, i) -> each + i > 3);
var expected = Lists.mutable.with(1, 2);
Assertions.assertEquals(expected, actual);
}
  • Added covariant overrides for sortThis().
  • Added covariant return types to methods in MultiReaderList that return this.
  • Added primitive singleton iterator.
  • Added toSortedList(Comparator) and toSortedListBy(Function) to primitive iterables.
@Test
public void toSortedListWithComparator()
{
var set = IntSets.immutable.with(1, 2, 3, 4, 5);
var list = set.toSortedList((i1, i2) -> i2 - i1);
var expected = IntLists.immutable.with(5, 4, 3, 2, 1);
Assertions.assertEquals(expected, list);
}

@Test
public void toSortedListByWithFunction()
{
var set = IntSets.immutable.with(1, 2, 3, 4, 5);
var list = set.toSortedListBy(Math::negateExact);
var expected = IntLists.immutable.with(5, 4, 3, 2, 1);
Assertions.assertEquals(expected, list);
}
  • Added isEqual and isSame to Pair and Triple as default methods.
@Test
public void isEqual()
{
Twin<String> pair1 = Tuples.twin("1", "1");
Assertions.assertTrue(pair1.isEqual());
Twin<String> pair2 = Tuples.twin("1", "2");
Assertions.assertFalse(pair2.isEqual());

Triplet<String> triple1 = Tuples.triplet("1", "1", "1");
Assertions.assertTrue(triple1.isEqual());
Triplet<String> triple2 = Tuples.triplet("1", "2", "1");
Assertions.assertFalse(triple2.isEqual());
}

@Test
public void isSame()
{
Twin<String> pair1 = Tuples.identicalTwin("1");
Assertions.assertTrue(pair1.isSame());
Twin<String> pair2 = Tuples.twin("1", new String("1"));
Assertions.assertFalse(pair2.isSame());

Triplet<String> triple1 = Tuples.identicalTriplet("1");
Assertions.assertTrue(triple1.isSame());
Triplet<String> triple2 = Tuples.triplet("1", new String("1"), "1");
Assertions.assertFalse(triple2.isSame());
}
  • Added converters from Pair and Triple to List types.
@Test
public void pairToList()
{
Twin<String> twin = Tuples.twin("1", "2");
var mutableList = Tuples.pairToList(twin);
var fixedSizeList = Tuples.pairToFixedSizeList(twin);
var immutableList = Tuples.pairToImmutableList(twin);
var expected = Lists.mutable.with("1", "2");
Assertions.assertEquals(expected, mutableList);
Assertions.assertEquals(expected, fixedSizeList);
Assertions.assertEquals(expected, immutableList);
}

@Test
public void tripleToList()
{
Triplet<String> triplet = Tuples.identicalTriplet("1");
var mutableList = Tuples.tripleToList(triplet);
var fixedSizeList = Tuples.tripleToFixedSizeList(triplet);
var immutableList = Tuples.tripleToImmutableList(triplet);
var expected = Lists.mutable.with("1", "1", "1");
Assertions.assertEquals(expected, mutableList);
Assertions.assertEquals(expected, fixedSizeList);
Assertions.assertEquals(expected, immutableList);
}
  • Added toImmutableSortedBagBy to Collectors2.
@Test
public void collectors2toImmutableSortedBagBy()
{
List<Integer> list = List.of(1, 2, 2, 3, 3, 3);
ImmutableSortedBag<Integer> bag =
list.stream().collect(
Collectors2.toImmutableSortedBagBy(Math::negateExact));
Comparator<Integer> c =
Functions.toIntComparator(Math::negateExact);
var expected = SortedBags.mutable.with(c, 1, 2, 2, 3, 3, 3);
Assertions.assertEquals(expected, bag);
}
  • Added toImmutableSortedMap and toImmutableSortedMapBy to Collectors2.
@Test
public void collects2toImmutableSortedMap()
{
List<Integer> list = List.of(1, 2, 3);
Comparator<Integer> c =
Functions.toIntComparator(Math::negateExact);
ImmutableSortedMap<Integer, String> map =
list.stream().collect(
Collectors2.toImmutableSortedMap(c, e -> e, String::valueOf));
var expected = SortedMaps.mutable.with(c, 1, "1", 2, "2", 3, "3");
Assertions.assertEquals(expected, map);
}

@Test
public void collects2toImmutableSortedMapBy()
{
List<Integer> list = List.of(1, 2, 3);
Function<Integer, Integer> negate = Math::negateExact;
ImmutableSortedMap<Integer, String> map =
list.stream().collect(
Collectors2.toImmutableSortedMapBy(negate, e -> e, String::valueOf));
Comparator<Integer> c = Comparator.comparing(negate);
var expected = SortedMaps.mutable.with(c, 1, "1", 2, "2", 3, "3");
Assertions.assertEquals(expected, map);
}
  • Added toSortedMap and toSortedMapBy to Collectors2.
@Test
public void collects2toSortedMap()
{
List<Integer> list = List.of(1, 2, 3);
Comparator<Integer> c =
Functions.toIntComparator(Math::negateExact);
MutableSortedMap<Integer, String> map =
list.stream().collect(
Collectors2.toSortedMap(c, e -> e, String::valueOf));
var expected = SortedMaps.mutable.with(c, 1, "1", 2, "2", 3, "3");
Assertions.assertEquals(expected, map);
}

@Test
public void collects2toSortedMapBy()
{
List<Integer> list = List.of(1, 2, 3);
Function<Integer, Integer> negate = Math::negateExact;
MutableSortedMap<Integer, String> map =
list.stream().collect(
Collectors2.toSortedMapBy(negate, e -> e, String::valueOf));
Comparator<Integer> c = Comparator.comparing(negate);
var expected = SortedMaps.mutable.with(c, 1, "1", 2, "2", 3, "3");
Assertions.assertEquals(expected, map);
}

Norwegian Website Translation

We now have a Norwegian translation of the Eclipse Collections web site.

Norwegian Translation of the Eclipse Collections website

Thank you to Rustam Mehmandarov for the contribution and to Mads Opheim for reviewing the translation!

Three new Eclipse Collections Katas in 2021

There were three new code katas created and added to the Eclipse Collections Kata repository in 2021. I wrote the following blog about the six Eclipse Collections Katas. The Eclipse Collections katas are the best hands-on resource for learning the Eclipse Collections library.

And there’s more!

Please refer to the 11.0 release notes for a more comprehensive set of changes made available in the 11.0 release. In there you will find details of optimizations, tech debt reduction, removed functionality, build changes, and a list of breaking changes.

Thank you

We continue to see an upward trend of downloads from Maven Central each month. From all the contributors and committers to the entire Eclipse Collections community… thank you for using Eclipse Collections!

Downloads of eclipse-collections for the past 12 months

We hope you enjoy all of the new features and improvements in the 11.0 release!

I am a Project Lead and Committer for the Eclipse Collections OSS project at the Eclipse Foundation. Eclipse Collections is open for contributions. If you like the library, you can let us know by starring it on GitHub.

--

--

Donald Raab
Donald Raab

Written by Donald Raab

Java Champion. Creator of the Eclipse Collections OSS Java library (https://github.com/eclipse/eclipse-collections). Inspired by Smalltalk. Opinions are my own.

No responses yet