Releases: brianburton/java-immutable-collections
Version 4.0.1 Releases
This release fixes a bug in Version 4.0.0a's implementation of IDeque.insertAllFirst()
that could, in some circumstances, return an IDeque
containing duplicated elements within the deque.
In addition, the IDeque
builders have been simplified and all iterator implementations have been improved.
Version 4.0.0a Released
This version contains a bug in IDeque.insertAllFirst(). Use Release 4.0.1 instead.
This version includes numerous changes to interface and class names to make the library easier to use and less verbose.
- Interface names have been shortened. The
JImmutable
prefix has been changed to a simpleI
. For example,JImmutableList
is nowIList
. - The single
JImmutables
class containing static factory methods has been replaced by collection specific factory method classes. These classes are named as the plural form of their corresponding collection's interface name. - A new collection,
IDeque
, has been added. This is similar toIList
but offers substantially better performance for single value get, insert, assign, and delete methods. It only allows insertion and deletion at the front and back of the collection. - New utility classes
Maybe
,NotNull
,Computation
, andResult
have been added.
For more information about the library see the projkect wiki.
Version 3.2.1 Released
This is a minor update to the 3.2.0 release with the following features:
- Reduced memory footprint of insert order maps.
- New factory methods in JImmutables class that create collectors for list maps and set maps.
- Improved README file with sample code.
Builds on features from 3.2.0:
- Improved hash array mapped trie implementation for arrays, maps, and sets.
- Reduced memory footprint of sets and maps.
- Common implementation for all HAMT based collection types (array, hash map, hash set).
- Adds put, putAll, setNextIndex methods to JImmutableArray builder.
- Adds forEach, forEachThrows, and arrayBuilder methods to JImmutableArray.
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>3.2.1</version>
</dependency>
Version 3.2.0 Released
Key features in this release include:
- Improved hash array mapped trie implementation for arrays, maps, and sets.
- Reduced memory footprint of sets and maps.
- Common implementation for all HAMT based collection types (array, hash map, hash set).
- Adds put, putAll, setNextIndex methods to JImmutableArray builder.
- Adds forEach, forEachThrows, and arrayBuilder methods to JImmutableArray.
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>3.2.0</version>
</dependency>
Version 3.1.0 Released
Key features in this release include:
- Dramatically reduces memory consumption of hash maps and sets (as created using JImmutables.map() and JImmutables.set()). Memory footprint of these collections is now very similar to that of standard JDK HashMap and HashSet.
- Adds reverse() method to JImmutableList to allow efficient creation of a list with all elements in reverse order.
- Adds isNonEmpty() methods to all collections.
- Adds forEach() and forEachThrows() methods to JImmutableListMap and JImmutableSetMap.
- Removes JImmutableList.insert(Iterable) because it made lists of collections cumbersome to work with. Use insertAll(Iterable) instead.
- Removes the Nullable annotation from JImmutableArray.getValueOr().
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>3.1.0</version>
</dependency>
Version 3.0.2 Released
Adds a couple of minor features:
- All Builder classes have a clear() method.
- Adds Temp class with quick value holder objects for use in lambdas.
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>3.0.2</version>
</dependency>
Version 3.0.0
This release includes some major improvements including:
- All streams can split evenly down to collections of approximately 32 values each. In previous releases splitting was collection dependent and relatively limited. This greatly improves support for parallel streams.
- JImmutableList provides full support for insertion and removal at any index within the list. In previous releases only JImmutableRandomAccessLists had this feature.
- JImmutableMaps have lower memory footprints than in previous releases.
- JImmutableList supports efficiently taking a sublist.
- The prefix() method returns a list consisting of the n elements from the beginning of the list.
- The suffix() method returns a list consisting of the n elements from the end of the list.
- The middle() method returns a list consisting of the elements from any two indices in the list.
- The slice() method is like the middle() method except it supports python style negative indexing and is forgiving of indexes past the end of the list.
- Builder classes have been added for JImmutableMap instances. For hash and sorted maps these builders are highly efficient and thread safe. For insert order maps the builder is just sugar over normal assign method calls.
- Builder classes have been added for JImmutableSet instances. For hash and sorted sets these builders are highly efficient and thread safe. For insert order sets the builder is just sugar over normal insert method calls.
- New forEach() and reduce() methods have been added for maps to eliminate the need for passing an Entry().
- The Cursor class has been removed. Cursors are incompatible with Streams and have higher overhead than Iterators so it was best to simplify the code base by removing them.
- The JImmutableRandomAccessList class has been removed. Having two list classes (especially one with such a long name) was difficult and its special features were moved into JImmutableList. The new JImmutableList implementation has much better performance than the old JImmutableRandomAccessList while supporting all of the same features.
- Many other minor improvements.
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>3.0.0</version>
</dependency>
Version 2.4.1
This patch release fixes an issue with JImmutables.ralistCollector() that could cause parallel collection to drop values in some circumstances.
Useful Links
Project Wiki
Collections Overview
Project Javadoc
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>2.4.1</version>
</dependency>
Version 2.4.0
This release is focused on performance improvements.
Bulk List Inserts
JImmutableList and JImmutableRandomAccessList have various methods for inserting entire collections of objects into a list. These methods include insertAll()
, insertAllFirst()
, and insertAllLast()
that accept Iterator, Cursor, Iterable, etc methods. This release optimizes many of these operations for better performance.
- Any insert operation that adds multiple values at once (i.e. from a collection, cursor, iterator, etc) to either the front or back of a JImmutableList or to the back of a JImmutableRandomAccessList.
- Stream collectors created using factory methods (see below) to build a new list from a stream.
- Deserializing JImmutableList and JImmutableRandomAccessList objects.
Stream Collector Factory Methods
New static factory methods have been added to JImmutables to simplify creation of collectors that build up new collections from a stream:
JImmutables.listCollector()
JImmutables.ralistCollector()
JImmutables.arrayCollector()
JImmutables.setCollector()
JImmutables.sortedSetCollector()
JImmutables.insertOrderSetCollector()
JImmutables.multisetCollector()
JImmutables.sortedMultisetCollector()
JImmutables.insertOrderMultisetCollector()
The old collector creation methods on list instances themselves do not use the faster logic so use of these new factory methods is encouraged unless you need to append to a non-empty list.
Useful Links
Project Wiki
Collections Overview
Project Javadoc
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>2.4.0</version>
</dependency>
Version 2.3.0
This release contains a mix of performance tweaks and convenience features.
Performance - Faster Builders
The mutable builder objects for JImmutableList and JImmutableRandomAccessList have been rewritten to use less memory. Previously they accumulated all of the values into an ArrayList and then built up an optimal immutable list when the build()
method is called. The new builders reduce memory consumption by constructing the lists as elements are added without any extra buffering. The list()
and ralist()
methods that build lists from arrays, iterators, and collections benefit transparently from this change as well.
Performance - update() Method for Maps
Maps are often used to accumulate values. The general pattern for this involves frequently calling get()
to find the current value (if any) for a key then calling assign()
with a modified value. This pattern leads to two round trips through the map. The new update()
method replaces these two round trips with a single one. The map traverses the tree to find the current value for the key (if any) then calls a lambda to get a new value and applies the change immediately at the node where it belongs. JImmutableListMap and JImmutableSetMap benefit transparently from this change as well.
Performance - Fast List Append for RandomAccessLists
When passing a JImmutableRandomAccessList to one of the insertAllFirst()
, insertAllLast()
, etc methods or another JImmutableRandomAccessList the append operation can now be performed in the same time as a single value insert. This change takes advantage of the nature of B-Trees to allow almost the entire structure of the smaller of the two lists to be directly added to the larger list to accomplish the append operation n a single update operation.
Utility - New transform() Methods for Lists
The new method constructs a new list of the same type containing new values produced by calling a lambda to convert each value to a new object type.
Utility - New Convenience Methods for Holders
This release adds several convenience methods to the Holder interface.
ifPresent()
: Takes a Consumer as its sole parameter. If the Holder is filled it calls the Consumer and passes it the value.map()
: Takes a Function as its sole parameter. If the Holder is filled it calls the Function and passes it the value.map()
returns a Holder containing the mapped value (if any).orElse()
: Alias forgetValueOr()
.orElseGet()
: Takes a Supplier as its sole parameter. If the Holder is empty it calls the Supplier and returns its result. Otherwise it returns its own value.orElseThrow()
: Takes a Supplier as its sole parameter. If the Holder is empty it calls the Supplier to obtain an Exception to throw. Otherwise it returns its own value.
Useful Links
Project Wiki
Collections Overview
Project Javadoc
Maven Coordinates
<dependency>
<groupId>org.javimmutable</groupId>
<artifactId>javimmutable-collections</artifactId>
<version>2.3.0</version>
</dependency>