Eclipse Collections 11.0 Released

Eclipse Collections Logo

Eclipse Collections 11.0 is here!

Eclipse Collections 11.0 in Maven Central
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 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.

  • Added anySatisfyWithOccurrences, allSatisfyWithOccurrences, noneSatisfyWithOccurrences, detectWithOccurrences to Bag.
  • Added putAllMapIterable method to MutableMap.
  • Added withMapIterable to MutableMap.
  • Added newWithMap and newWithMapIterable to ImmutableMap.
  • 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.
  • Added ClassComparer utility.

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

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Donald Raab

Donald Raab

Java Champion. Creator of the Eclipse Collections OSS Java library (http://www.eclipse.org/collections/). Inspired by Smalltalk. Opinions are my own.