Skip to content

Commit

Permalink
Remove dependencies on primitive collection implementations.
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Raab <Donald.Raab@bnymellon.com>
  • Loading branch information
donraab committed Mar 6, 2022
1 parent 737ec1c commit 0f1b853
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Goldman Sachs.
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand Down Expand Up @@ -50,6 +50,14 @@
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.BooleanLists;
import org.eclipse.collections.api.factory.primitive.ByteLists;
import org.eclipse.collections.api.factory.primitive.CharLists;
import org.eclipse.collections.api.factory.primitive.DoubleLists;
import org.eclipse.collections.api.factory.primitive.FloatLists;
import org.eclipse.collections.api.factory.primitive.IntLists;
import org.eclipse.collections.api.factory.primitive.LongLists;
import org.eclipse.collections.api.factory.primitive.ShortLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.MutableBooleanList;
import org.eclipse.collections.api.list.primitive.MutableByteList;
Expand All @@ -71,14 +79,6 @@
import org.eclipse.collections.impl.block.factory.Procedures2;
import org.eclipse.collections.impl.block.procedure.MapCollectProcedure;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.CharArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.multimap.list.FastListMultimap;
import org.eclipse.collections.impl.partition.list.PartitionFastList;
Expand Down Expand Up @@ -449,7 +449,7 @@ public static <T> MutableBooleanList collectBoolean(T[] objectArray, BooleanFunc
{
throw new IllegalArgumentException("Cannot perform a collectBoolean on null");
}
return ArrayIterate.collectBoolean(objectArray, booleanFunction, new BooleanArrayList(objectArray.length));
return ArrayIterate.collectBoolean(objectArray, booleanFunction, BooleanLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -480,7 +480,7 @@ public static <T> MutableByteList collectByte(T[] objectArray, ByteFunction<? su
{
throw new IllegalArgumentException("Cannot perform a collectByte on null");
}
return ArrayIterate.collectByte(objectArray, byteFunction, new ByteArrayList(objectArray.length));
return ArrayIterate.collectByte(objectArray, byteFunction, ByteLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -511,7 +511,7 @@ public static <T> MutableCharList collectChar(T[] objectArray, CharFunction<? su
{
throw new IllegalArgumentException("Cannot perform a collectChar on null");
}
return ArrayIterate.collectChar(objectArray, charFunction, new CharArrayList(objectArray.length));
return ArrayIterate.collectChar(objectArray, charFunction, CharLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -542,7 +542,7 @@ public static <T> MutableDoubleList collectDouble(T[] objectArray, DoubleFunctio
{
throw new IllegalArgumentException("Cannot perform a collectDouble on null");
}
return ArrayIterate.collectDouble(objectArray, doubleFunction, new DoubleArrayList(objectArray.length));
return ArrayIterate.collectDouble(objectArray, doubleFunction, DoubleLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -573,7 +573,7 @@ public static <T> MutableFloatList collectFloat(T[] objectArray, FloatFunction<?
{
throw new IllegalArgumentException("Cannot perform a collectFloat on null");
}
return ArrayIterate.collectFloat(objectArray, floatFunction, new FloatArrayList(objectArray.length));
return ArrayIterate.collectFloat(objectArray, floatFunction, FloatLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -606,7 +606,7 @@ public static <T> MutableIntList collectInt(
{
throw new IllegalArgumentException("Cannot perform a collectInt on null");
}
return ArrayIterate.collectInt(objectArray, intFunction, new IntArrayList(objectArray.length));
return ArrayIterate.collectInt(objectArray, intFunction, IntLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -639,7 +639,7 @@ public static <T> MutableLongList collectLong(
{
throw new IllegalArgumentException("Cannot perform a collectLong on null");
}
return ArrayIterate.collectLong(objectArray, longFunction, new LongArrayList(objectArray.length));
return ArrayIterate.collectLong(objectArray, longFunction, LongLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down Expand Up @@ -672,7 +672,7 @@ public static <T> MutableShortList collectShort(
{
throw new IllegalArgumentException("Cannot perform a collectShort on null");
}
return ArrayIterate.collectShort(objectArray, shortFunction, new ShortArrayList(objectArray.length));
return ArrayIterate.collectShort(objectArray, shortFunction, ShortLists.mutable.withInitialCapacity(objectArray.length));
}

/**
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Goldman Sachs.
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand Down Expand Up @@ -52,6 +52,14 @@
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.BooleanLists;
import org.eclipse.collections.api.factory.primitive.ByteLists;
import org.eclipse.collections.api.factory.primitive.CharLists;
import org.eclipse.collections.api.factory.primitive.DoubleLists;
import org.eclipse.collections.api.factory.primitive.FloatLists;
import org.eclipse.collections.api.factory.primitive.IntLists;
import org.eclipse.collections.api.factory.primitive.LongLists;
import org.eclipse.collections.api.factory.primitive.ShortLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.MutableMapIterable;
Expand All @@ -65,14 +73,6 @@
import org.eclipse.collections.impl.block.procedure.MutatingAggregationProcedure;
import org.eclipse.collections.impl.block.procedure.NonMutatingAggregationProcedure;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.CharArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.multimap.list.FastListMultimap;
import org.eclipse.collections.impl.partition.list.PartitionFastList;
Expand Down Expand Up @@ -385,7 +385,7 @@ public static <T> MutableBooleanCollection collectBoolean(
Iterator<T> iterator,
BooleanFunction<? super T> booleanFunction)
{
MutableBooleanCollection result = new BooleanArrayList();
MutableBooleanCollection result = BooleanLists.mutable.empty();
while (iterator.hasNext())
{
result.add(booleanFunction.booleanValueOf(iterator.next()));
Expand Down Expand Up @@ -415,7 +415,7 @@ public static <T> MutableByteCollection collectByte(
Iterator<T> iterator,
ByteFunction<? super T> byteFunction)
{
MutableByteCollection result = new ByteArrayList();
MutableByteCollection result = ByteLists.mutable.empty();
while (iterator.hasNext())
{
result.add(byteFunction.byteValueOf(iterator.next()));
Expand Down Expand Up @@ -445,7 +445,7 @@ public static <T> MutableCharCollection collectChar(
Iterator<T> iterator,
CharFunction<? super T> charFunction)
{
MutableCharCollection result = new CharArrayList();
MutableCharCollection result = CharLists.mutable.empty();
while (iterator.hasNext())
{
result.add(charFunction.charValueOf(iterator.next()));
Expand Down Expand Up @@ -475,7 +475,7 @@ public static <T> MutableDoubleCollection collectDouble(
Iterator<T> iterator,
DoubleFunction<? super T> doubleFunction)
{
MutableDoubleCollection result = new DoubleArrayList();
MutableDoubleCollection result = DoubleLists.mutable.empty();
while (iterator.hasNext())
{
result.add(doubleFunction.doubleValueOf(iterator.next()));
Expand Down Expand Up @@ -505,7 +505,7 @@ public static <T> MutableFloatCollection collectFloat(
Iterator<T> iterator,
FloatFunction<? super T> floatFunction)
{
MutableFloatCollection result = new FloatArrayList();
MutableFloatCollection result = FloatLists.mutable.empty();
while (iterator.hasNext())
{
result.add(floatFunction.floatValueOf(iterator.next()));
Expand Down Expand Up @@ -535,7 +535,7 @@ public static <T> MutableIntCollection collectInt(
Iterator<T> iterator,
IntFunction<? super T> intFunction)
{
MutableIntCollection result = new IntArrayList();
MutableIntCollection result = IntLists.mutable.empty();
while (iterator.hasNext())
{
result.add(intFunction.intValueOf(iterator.next()));
Expand Down Expand Up @@ -565,7 +565,7 @@ public static <T> MutableLongCollection collectLong(
Iterator<T> iterator,
LongFunction<? super T> longFunction)
{
MutableLongCollection result = new LongArrayList();
MutableLongCollection result = LongLists.mutable.empty();
while (iterator.hasNext())
{
result.add(longFunction.longValueOf(iterator.next()));
Expand Down Expand Up @@ -595,7 +595,7 @@ public static <T> MutableShortCollection collectShort(
Iterator<T> iterator,
ShortFunction<? super T> shortFunction)
{
MutableShortCollection result = new ShortArrayList();
MutableShortCollection result = ShortLists.mutable.empty();
while (iterator.hasNext())
{
result.add(shortFunction.shortValueOf(iterator.next()));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Goldman Sachs and others.
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
Expand Down Expand Up @@ -54,6 +54,14 @@
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.BooleanLists;
import org.eclipse.collections.api.factory.primitive.ByteLists;
import org.eclipse.collections.api.factory.primitive.CharLists;
import org.eclipse.collections.api.factory.primitive.DoubleLists;
import org.eclipse.collections.api.factory.primitive.FloatLists;
import org.eclipse.collections.api.factory.primitive.IntLists;
import org.eclipse.collections.api.factory.primitive.LongLists;
import org.eclipse.collections.api.factory.primitive.ShortLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.MutableBooleanList;
import org.eclipse.collections.api.list.primitive.MutableByteList;
Expand All @@ -77,14 +85,6 @@
import org.eclipse.collections.impl.block.procedure.MutatingAggregationProcedure;
import org.eclipse.collections.impl.block.procedure.NonMutatingAggregationProcedure;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.CharArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
import org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.map.mutable.primitive.ObjectDoubleHashMap;
import org.eclipse.collections.impl.map.mutable.primitive.ObjectLongHashMap;
Expand Down Expand Up @@ -378,7 +378,7 @@ public static <T> MutableBooleanList collectBoolean(
List<T> list,
BooleanFunction<? super T> booleanFunction)
{
return RandomAccessListIterate.collectBoolean(list, booleanFunction, new BooleanArrayList(list.size()));
return RandomAccessListIterate.collectBoolean(list, booleanFunction, BooleanLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -404,7 +404,7 @@ public static <T> MutableByteList collectByte(
List<T> list,
ByteFunction<? super T> byteFunction)
{
return RandomAccessListIterate.collectByte(list, byteFunction, new ByteArrayList(list.size()));
return RandomAccessListIterate.collectByte(list, byteFunction, ByteLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -430,7 +430,7 @@ public static <T> MutableCharList collectChar(
List<T> list,
CharFunction<? super T> charFunction)
{
return RandomAccessListIterate.collectChar(list, charFunction, new CharArrayList(list.size()));
return RandomAccessListIterate.collectChar(list, charFunction, CharLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -456,7 +456,7 @@ public static <T> MutableDoubleList collectDouble(
List<T> list,
DoubleFunction<? super T> doubleFunction)
{
return RandomAccessListIterate.collectDouble(list, doubleFunction, new DoubleArrayList(list.size()));
return RandomAccessListIterate.collectDouble(list, doubleFunction, DoubleLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -482,7 +482,7 @@ public static <T> MutableFloatList collectFloat(
List<T> list,
FloatFunction<? super T> floatFunction)
{
return RandomAccessListIterate.collectFloat(list, floatFunction, new FloatArrayList(list.size()));
return RandomAccessListIterate.collectFloat(list, floatFunction, FloatLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -508,7 +508,7 @@ public static <T> MutableIntList collectInt(
List<T> list,
IntFunction<? super T> intFunction)
{
return RandomAccessListIterate.collectInt(list, intFunction, new IntArrayList(list.size()));
return RandomAccessListIterate.collectInt(list, intFunction, IntLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -534,7 +534,7 @@ public static <T> MutableLongList collectLong(
List<T> list,
LongFunction<? super T> longFunction)
{
return RandomAccessListIterate.collectLong(list, longFunction, new LongArrayList(list.size()));
return RandomAccessListIterate.collectLong(list, longFunction, LongLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand All @@ -560,7 +560,7 @@ public static <T> MutableShortList collectShort(
List<T> list,
ShortFunction<? super T> shortFunction)
{
return RandomAccessListIterate.collectShort(list, shortFunction, new ShortArrayList(list.size()));
return RandomAccessListIterate.collectShort(list, shortFunction, ShortLists.mutable.withInitialCapacity(list.size()));
}

/**
Expand Down

0 comments on commit 0f1b853

Please sign in to comment.