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 9, 2022
1 parent acdeefc commit 3abce27
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 126 deletions.
@@ -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 @@ -44,6 +44,14 @@
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.collection.MutableCollection;
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.ImmutableList;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.ParallelListIterable;
Expand All @@ -55,6 +63,14 @@
import org.eclipse.collections.api.list.primitive.ImmutableIntList;
import org.eclipse.collections.api.list.primitive.ImmutableLongList;
import org.eclipse.collections.api.list.primitive.ImmutableShortList;
import org.eclipse.collections.api.list.primitive.MutableBooleanList;
import org.eclipse.collections.api.list.primitive.MutableByteList;
import org.eclipse.collections.api.list.primitive.MutableCharList;
import org.eclipse.collections.api.list.primitive.MutableDoubleList;
import org.eclipse.collections.api.list.primitive.MutableFloatList;
import org.eclipse.collections.api.list.primitive.MutableIntList;
import org.eclipse.collections.api.list.primitive.MutableLongList;
import org.eclipse.collections.api.list.primitive.MutableShortList;
import org.eclipse.collections.api.multimap.MutableMultimap;
import org.eclipse.collections.api.multimap.list.ImmutableListMultimap;
import org.eclipse.collections.api.ordered.OrderedIterable;
Expand All @@ -81,14 +97,6 @@
import org.eclipse.collections.impl.lazy.ReverseIterable;
import org.eclipse.collections.impl.lazy.parallel.list.ListIterableParallelIterable;
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.multimap.list.FastListMultimap;
import org.eclipse.collections.impl.stack.mutable.ArrayStack;
import org.eclipse.collections.impl.utility.Iterate;
Expand Down Expand Up @@ -305,63 +313,63 @@ public <V> ImmutableList<V> collect(Function<? super T, ? extends V> function)
@Override
public ImmutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction)
{
BooleanArrayList result = new BooleanArrayList(this.size());
MutableBooleanList result = BooleanLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectBooleanProcedure<>(booleanFunction, result));
return result.toImmutable();
}

@Override
public ImmutableByteList collectByte(ByteFunction<? super T> byteFunction)
{
ByteArrayList result = new ByteArrayList(this.size());
MutableByteList result = ByteLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectByteProcedure<>(byteFunction, result));
return result.toImmutable();
}

@Override
public ImmutableCharList collectChar(CharFunction<? super T> charFunction)
{
CharArrayList result = new CharArrayList(this.size());
MutableCharList result = CharLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result.toImmutable();
}

@Override
public ImmutableDoubleList collectDouble(DoubleFunction<? super T> doubleFunction)
{
DoubleArrayList result = new DoubleArrayList(this.size());
MutableDoubleList result = DoubleLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectDoubleProcedure<>(doubleFunction, result));
return result.toImmutable();
}

@Override
public ImmutableFloatList collectFloat(FloatFunction<? super T> floatFunction)
{
FloatArrayList result = new FloatArrayList(this.size());
MutableFloatList result = FloatLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectFloatProcedure<>(floatFunction, result));
return result.toImmutable();
}

@Override
public ImmutableIntList collectInt(IntFunction<? super T> intFunction)
{
IntArrayList result = new IntArrayList(this.size());
MutableIntList result = IntLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result.toImmutable();
}

@Override
public ImmutableLongList collectLong(LongFunction<? super T> longFunction)
{
LongArrayList result = new LongArrayList(this.size());
MutableLongList result = LongLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectLongProcedure<>(longFunction, result));
return result.toImmutable();
}

@Override
public ImmutableShortList collectShort(ShortFunction<? super T> shortFunction)
{
ShortArrayList result = new ShortArrayList(this.size());
MutableShortList result = ShortLists.mutable.withInitialCapacity(this.size());
this.forEach(new CollectShortProcedure<>(shortFunction, result));
return result.toImmutable();
}
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 @@ -31,6 +31,14 @@
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
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 @@ -45,14 +53,6 @@
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.block.procedure.CollectionAddProcedure;
import org.eclipse.collections.impl.lazy.ReverseIterable;
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.multimap.list.FastListMultimap;
import org.eclipse.collections.impl.utility.ArrayIterate;
import org.eclipse.collections.impl.utility.ArrayListIterate;
Expand Down Expand Up @@ -331,63 +331,63 @@ public <V> ArrayListAdapter<V> collect(Function<? super T, ? extends V> function
@Override
public MutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction)
{
BooleanArrayList result = new BooleanArrayList(this.size());
MutableBooleanList result = BooleanLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(booleanFunction.booleanValueOf(each)));
return result;
}

@Override
public MutableByteList collectByte(ByteFunction<? super T> byteFunction)
{
ByteArrayList result = new ByteArrayList(this.size());
MutableByteList result = ByteLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(byteFunction.byteValueOf(each)));
return result;
}

@Override
public MutableCharList collectChar(CharFunction<? super T> charFunction)
{
CharArrayList result = new CharArrayList(this.size());
MutableCharList result = CharLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(charFunction.charValueOf(each)));
return result;
}

@Override
public MutableDoubleList collectDouble(DoubleFunction<? super T> doubleFunction)
{
DoubleArrayList result = new DoubleArrayList(this.size());
MutableDoubleList result = DoubleLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(doubleFunction.doubleValueOf(each)));
return result;
}

@Override
public MutableFloatList collectFloat(FloatFunction<? super T> floatFunction)
{
FloatArrayList result = new FloatArrayList(this.size());
MutableFloatList result = FloatLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(floatFunction.floatValueOf(each)));
return result;
}

@Override
public MutableIntList collectInt(IntFunction<? super T> intFunction)
{
IntArrayList result = new IntArrayList(this.size());
MutableIntList result = IntLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(intFunction.intValueOf(each)));
return result;
}

@Override
public MutableLongList collectLong(LongFunction<? super T> longFunction)
{
LongArrayList result = new LongArrayList(this.size());
MutableLongList result = LongLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(longFunction.longValueOf(each)));
return result;
}

@Override
public MutableShortList collectShort(ShortFunction<? super T> shortFunction)
{
ShortArrayList result = new ShortArrayList(this.size());
MutableShortList result = ShortLists.mutable.withInitialCapacity(this.size());
this.each(each -> result.add(shortFunction.shortValueOf(each)));
return result;
}
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 @@ -47,22 +47,6 @@
import org.eclipse.collections.api.partition.list.PartitionMutableList;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.block.procedure.CollectionAddProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectBooleanProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectByteProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectCharProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectDoubleProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectFloatProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectIntProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectLongProcedure;
import org.eclipse.collections.impl.block.procedure.primitive.CollectShortProcedure;
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.multimap.list.FastListMultimap;
import org.eclipse.collections.impl.utility.ArrayIterate;
import org.eclipse.collections.impl.utility.ListIterate;
Expand Down Expand Up @@ -350,65 +334,49 @@ public <V> MutableList<V> collect(Function<? super T, ? extends V> function)
@Override
public MutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction)
{
BooleanArrayList result = new BooleanArrayList(this.size());
this.forEach(new CollectBooleanProcedure<>(booleanFunction, result));
return result;
return RandomAccessListIterate.collectBoolean(this.delegate, booleanFunction);
}

@Override
public MutableByteList collectByte(ByteFunction<? super T> byteFunction)
{
ByteArrayList result = new ByteArrayList(this.size());
this.forEach(new CollectByteProcedure<>(byteFunction, result));
return result;
return RandomAccessListIterate.collectByte(this.delegate, byteFunction);
}

@Override
public MutableCharList collectChar(CharFunction<? super T> charFunction)
{
CharArrayList result = new CharArrayList(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result;
return RandomAccessListIterate.collectChar(this.delegate, charFunction);
}

@Override
public MutableDoubleList collectDouble(DoubleFunction<? super T> doubleFunction)
{
DoubleArrayList result = new DoubleArrayList(this.size());
this.forEach(new CollectDoubleProcedure<>(doubleFunction, result));
return result;
return RandomAccessListIterate.collectDouble(this.delegate, doubleFunction);
}

@Override
public MutableFloatList collectFloat(FloatFunction<? super T> floatFunction)
{
FloatArrayList result = new FloatArrayList(this.size());
this.forEach(new CollectFloatProcedure<>(floatFunction, result));
return result;
return RandomAccessListIterate.collectFloat(this.delegate, floatFunction);
}

@Override
public MutableIntList collectInt(IntFunction<? super T> intFunction)
{
IntArrayList result = new IntArrayList(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result;
return RandomAccessListIterate.collectInt(this.delegate, intFunction);
}

@Override
public MutableLongList collectLong(LongFunction<? super T> longFunction)
{
LongArrayList result = new LongArrayList(this.size());
this.forEach(new CollectLongProcedure<>(longFunction, result));
return result;
return RandomAccessListIterate.collectLong(this.delegate, longFunction);
}

@Override
public MutableShortList collectShort(ShortFunction<? super T> shortFunction)
{
ShortArrayList result = new ShortArrayList(this.size());
this.forEach(new CollectShortProcedure<>(shortFunction, result));
return result;
return RandomAccessListIterate.collectShort(this.delegate, shortFunction);
}

@Override
Expand Down

0 comments on commit 3abce27

Please sign in to comment.