Skip to content

4.0.0 (September 2013)

Compare
Choose a tag to compare
@goldmansachs goldmansachs released this 11 Sep 17:58
· 519 commits to master since this release

Binaries

gs-collections-4.0.0.zip

Javadoc

4.0.0 Javadoc

JDiff

API differences between 3.0.0 and 4.0.0

New Functionality

Version 4.0 completes the immutable primitive collections work started in 3.2.0. All the primitive collections now have immutable counterparts.

Immutable Primitive Collections

4.0 has immutable primitive sets, stacks, bags and maps. They can each be created using either the toImmutable() method or the primitive collection factories.

MutableIntSet set = IntHashSet.newSetWith(1, 2, 3);
ImmutableIntSet immutableSet = set.toImmutable();

ImmutableIntSet immutableSet2 = IntSets.immutable.of(1, 2, 3);
MutableIntStack stack = IntArrayStack.newStackWith(1, 2, 3);
ImmutableIntStack immutableStack = stack.toImmutable();

ImmutableIntStack immutableStack2 = IntStacks.immutable.of(1, 2, 3);
MutableIntBag bag = IntHashBag.newBagWith(1, 2, 3);
ImmutableIntBag immutableBag = bag.toImmutable();

ImmutableIntBag immutableBag2 = IntBags.immutable.of(1, 2, 3);
MutableIntCharMap map = IntCharHashMap.newWithKeysValues(1, 'a', 2, 'b', 3, 'c');
ImmutableIntCharMap immutableMap = map.toImmutable();

ImmutableIntCharMap immutableMap2 = IntCharMaps.immutable.ofAll(map);

collect() Methods on RichIterable

The collect() methods on RichIterable are similar to collect(), but they take a primitive function and return a primitive collection. There are variants for all eight primitives.

  • collectBoolean()
  • collectByte()
  • collectChar()
  • collectShort()
  • collectInt()
  • collectFloat()
  • collectLong()
  • collectDouble()

More API on Primitive Maps

Primitive maps now include additional API from the non-primitive variants.

putAll()

Copies all of the mappings from the map parameter to this map.

keySet()

Returns a set view of the keys contained in the map. Changes to the map are reflected in the set, and vice versa. The set supports removal, which removes the corresponding mapping from the map. It does not support add() or addAll().

values()

Returns a collection view of the values contained in the map. Changes to the map are reflected in the collection, and vice versa. The collection supports removal, which removes the corresponding mapping from the map. It does not support add() or addAll().