diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/immutable/AbstractImmutableList.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/immutable/AbstractImmutableList.java index b8ef2f5013..cf2711bb58 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/immutable/AbstractImmutableList.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/immutable/AbstractImmutableList.java @@ -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. @@ -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; @@ -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; @@ -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; @@ -305,7 +313,7 @@ public ImmutableList collect(Function function) @Override public ImmutableBooleanList collectBoolean(BooleanFunction booleanFunction) { - BooleanArrayList result = new BooleanArrayList(this.size()); + MutableBooleanList result = BooleanLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectBooleanProcedure<>(booleanFunction, result)); return result.toImmutable(); } @@ -313,7 +321,7 @@ public ImmutableBooleanList collectBoolean(BooleanFunction booleanFun @Override public ImmutableByteList collectByte(ByteFunction byteFunction) { - ByteArrayList result = new ByteArrayList(this.size()); + MutableByteList result = ByteLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectByteProcedure<>(byteFunction, result)); return result.toImmutable(); } @@ -321,7 +329,7 @@ public ImmutableByteList collectByte(ByteFunction byteFunction) @Override public ImmutableCharList collectChar(CharFunction charFunction) { - CharArrayList result = new CharArrayList(this.size()); + MutableCharList result = CharLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectCharProcedure<>(charFunction, result)); return result.toImmutable(); } @@ -329,7 +337,7 @@ public ImmutableCharList collectChar(CharFunction charFunction) @Override public ImmutableDoubleList collectDouble(DoubleFunction doubleFunction) { - DoubleArrayList result = new DoubleArrayList(this.size()); + MutableDoubleList result = DoubleLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectDoubleProcedure<>(doubleFunction, result)); return result.toImmutable(); } @@ -337,7 +345,7 @@ public ImmutableDoubleList collectDouble(DoubleFunction doubleFunctio @Override public ImmutableFloatList collectFloat(FloatFunction floatFunction) { - FloatArrayList result = new FloatArrayList(this.size()); + MutableFloatList result = FloatLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectFloatProcedure<>(floatFunction, result)); return result.toImmutable(); } @@ -345,7 +353,7 @@ public ImmutableFloatList collectFloat(FloatFunction floatFunction) @Override public ImmutableIntList collectInt(IntFunction intFunction) { - IntArrayList result = new IntArrayList(this.size()); + MutableIntList result = IntLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectIntProcedure<>(intFunction, result)); return result.toImmutable(); } @@ -353,7 +361,7 @@ public ImmutableIntList collectInt(IntFunction intFunction) @Override public ImmutableLongList collectLong(LongFunction longFunction) { - LongArrayList result = new LongArrayList(this.size()); + MutableLongList result = LongLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectLongProcedure<>(longFunction, result)); return result.toImmutable(); } @@ -361,7 +369,7 @@ public ImmutableLongList collectLong(LongFunction longFunction) @Override public ImmutableShortList collectShort(ShortFunction shortFunction) { - ShortArrayList result = new ShortArrayList(this.size()); + MutableShortList result = ShortLists.mutable.withInitialCapacity(this.size()); this.forEach(new CollectShortProcedure<>(shortFunction, result)); return result.toImmutable(); } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/ArrayListAdapter.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/ArrayListAdapter.java index e5dcf17052..4f85998930 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/ArrayListAdapter.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/ArrayListAdapter.java @@ -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. @@ -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; @@ -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; @@ -331,7 +331,7 @@ public ArrayListAdapter collect(Function function @Override public MutableBooleanList collectBoolean(BooleanFunction booleanFunction) { - BooleanArrayList result = new BooleanArrayList(this.size()); + MutableBooleanList result = BooleanLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(booleanFunction.booleanValueOf(each))); return result; } @@ -339,7 +339,7 @@ public MutableBooleanList collectBoolean(BooleanFunction booleanFunct @Override public MutableByteList collectByte(ByteFunction byteFunction) { - ByteArrayList result = new ByteArrayList(this.size()); + MutableByteList result = ByteLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(byteFunction.byteValueOf(each))); return result; } @@ -347,7 +347,7 @@ public MutableByteList collectByte(ByteFunction byteFunction) @Override public MutableCharList collectChar(CharFunction charFunction) { - CharArrayList result = new CharArrayList(this.size()); + MutableCharList result = CharLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(charFunction.charValueOf(each))); return result; } @@ -355,7 +355,7 @@ public MutableCharList collectChar(CharFunction charFunction) @Override public MutableDoubleList collectDouble(DoubleFunction doubleFunction) { - DoubleArrayList result = new DoubleArrayList(this.size()); + MutableDoubleList result = DoubleLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(doubleFunction.doubleValueOf(each))); return result; } @@ -363,7 +363,7 @@ public MutableDoubleList collectDouble(DoubleFunction doubleFunction) @Override public MutableFloatList collectFloat(FloatFunction floatFunction) { - FloatArrayList result = new FloatArrayList(this.size()); + MutableFloatList result = FloatLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(floatFunction.floatValueOf(each))); return result; } @@ -371,7 +371,7 @@ public MutableFloatList collectFloat(FloatFunction floatFunction) @Override public MutableIntList collectInt(IntFunction intFunction) { - IntArrayList result = new IntArrayList(this.size()); + MutableIntList result = IntLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(intFunction.intValueOf(each))); return result; } @@ -379,7 +379,7 @@ public MutableIntList collectInt(IntFunction intFunction) @Override public MutableLongList collectLong(LongFunction longFunction) { - LongArrayList result = new LongArrayList(this.size()); + MutableLongList result = LongLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(longFunction.longValueOf(each))); return result; } @@ -387,7 +387,7 @@ public MutableLongList collectLong(LongFunction longFunction) @Override public MutableShortList collectShort(ShortFunction shortFunction) { - ShortArrayList result = new ShortArrayList(this.size()); + MutableShortList result = ShortLists.mutable.withInitialCapacity(this.size()); this.each(each -> result.add(shortFunction.shortValueOf(each))); return result; } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/RandomAccessListAdapter.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/RandomAccessListAdapter.java index 95762743de..0a143db49f 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/RandomAccessListAdapter.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/RandomAccessListAdapter.java @@ -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. @@ -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; @@ -350,65 +334,49 @@ public MutableList collect(Function function) @Override public MutableBooleanList collectBoolean(BooleanFunction 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 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 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 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 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 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 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 shortFunction) { - ShortArrayList result = new ShortArrayList(this.size()); - this.forEach(new CollectShortProcedure<>(shortFunction, result)); - return result; + return RandomAccessListIterate.collectShort(this.delegate, shortFunction); } @Override diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/immutable/AbstractImmutableSet.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/immutable/AbstractImmutableSet.java index 278396fe83..fc735274de 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/immutable/AbstractImmutableSet.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/immutable/AbstractImmutableSet.java @@ -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. @@ -32,6 +32,14 @@ import org.eclipse.collections.api.block.procedure.Procedure; import org.eclipse.collections.api.collection.MutableCollection; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.primitive.BooleanSets; +import org.eclipse.collections.api.factory.primitive.ByteSets; +import org.eclipse.collections.api.factory.primitive.CharSets; +import org.eclipse.collections.api.factory.primitive.DoubleSets; +import org.eclipse.collections.api.factory.primitive.FloatSets; +import org.eclipse.collections.api.factory.primitive.IntSets; +import org.eclipse.collections.api.factory.primitive.LongSets; +import org.eclipse.collections.api.factory.primitive.ShortSets; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.multimap.MutableMultimap; import org.eclipse.collections.api.multimap.set.ImmutableSetMultimap; @@ -85,14 +93,6 @@ import org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap; import org.eclipse.collections.impl.partition.set.PartitionUnifiedSet; import org.eclipse.collections.impl.set.mutable.UnifiedSet; -import org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.CharHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.FloatHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ShortHashSet; import org.eclipse.collections.impl.utility.Iterate; import org.eclipse.collections.impl.utility.internal.SetIterables; @@ -224,7 +224,7 @@ public ImmutableSet collect(Function function) @Override public ImmutableBooleanSet collectBoolean(BooleanFunction booleanFunction) { - MutableBooleanSet result = new BooleanHashSet(); + MutableBooleanSet result = BooleanSets.mutable.empty(); this.forEach(new CollectBooleanProcedure<>(booleanFunction, result)); return result.toImmutable(); } @@ -232,7 +232,7 @@ public ImmutableBooleanSet collectBoolean(BooleanFunction booleanFunc @Override public ImmutableByteSet collectByte(ByteFunction byteFunction) { - MutableByteSet result = new ByteHashSet(); + MutableByteSet result = ByteSets.mutable.empty(); this.forEach(new CollectByteProcedure<>(byteFunction, result)); return result.toImmutable(); } @@ -240,7 +240,7 @@ public ImmutableByteSet collectByte(ByteFunction byteFunction) @Override public ImmutableCharSet collectChar(CharFunction charFunction) { - MutableCharSet result = new CharHashSet(this.size()); + MutableCharSet result = CharSets.mutable.empty(); this.forEach(new CollectCharProcedure<>(charFunction, result)); return result.toImmutable(); } @@ -248,7 +248,7 @@ public ImmutableCharSet collectChar(CharFunction charFunction) @Override public ImmutableDoubleSet collectDouble(DoubleFunction doubleFunction) { - MutableDoubleSet result = new DoubleHashSet(this.size()); + MutableDoubleSet result = DoubleSets.mutable.empty(); this.forEach(new CollectDoubleProcedure<>(doubleFunction, result)); return result.toImmutable(); } @@ -256,7 +256,7 @@ public ImmutableDoubleSet collectDouble(DoubleFunction doubleFunction @Override public ImmutableFloatSet collectFloat(FloatFunction floatFunction) { - MutableFloatSet result = new FloatHashSet(this.size()); + MutableFloatSet result = FloatSets.mutable.empty(); this.forEach(new CollectFloatProcedure<>(floatFunction, result)); return result.toImmutable(); } @@ -264,7 +264,7 @@ public ImmutableFloatSet collectFloat(FloatFunction floatFunction) @Override public ImmutableIntSet collectInt(IntFunction intFunction) { - MutableIntSet result = new IntHashSet(this.size()); + MutableIntSet result = IntSets.mutable.empty(); this.forEach(new CollectIntProcedure<>(intFunction, result)); return result.toImmutable(); } @@ -272,7 +272,7 @@ public ImmutableIntSet collectInt(IntFunction intFunction) @Override public ImmutableLongSet collectLong(LongFunction longFunction) { - MutableLongSet result = new LongHashSet(this.size()); + MutableLongSet result = LongSets.mutable.empty(); this.forEach(new CollectLongProcedure<>(longFunction, result)); return result.toImmutable(); } @@ -280,7 +280,7 @@ public ImmutableLongSet collectLong(LongFunction longFunction) @Override public ImmutableShortSet collectShort(ShortFunction shortFunction) { - MutableShortSet result = new ShortHashSet(this.size()); + MutableShortSet result = ShortSets.mutable.empty(); this.forEach(new CollectShortProcedure<>(shortFunction, result)); return result.toImmutable(); } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/AbstractMutableSet.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/AbstractMutableSet.java index 018930841d..17626e6f58 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/AbstractMutableSet.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/AbstractMutableSet.java @@ -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. @@ -27,6 +27,14 @@ import org.eclipse.collections.api.block.predicate.Predicate2; import org.eclipse.collections.api.block.procedure.Procedure; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.primitive.BooleanSets; +import org.eclipse.collections.api.factory.primitive.ByteSets; +import org.eclipse.collections.api.factory.primitive.CharSets; +import org.eclipse.collections.api.factory.primitive.DoubleSets; +import org.eclipse.collections.api.factory.primitive.FloatSets; +import org.eclipse.collections.api.factory.primitive.IntSets; +import org.eclipse.collections.api.factory.primitive.LongSets; +import org.eclipse.collections.api.factory.primitive.ShortSets; import org.eclipse.collections.api.ordered.OrderedIterable; import org.eclipse.collections.api.partition.set.PartitionMutableSet; import org.eclipse.collections.api.set.ImmutableSet; @@ -56,14 +64,6 @@ import org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection; import org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap; import org.eclipse.collections.impl.partition.set.PartitionUnifiedSet; -import org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.CharHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.FloatHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ShortHashSet; import org.eclipse.collections.impl.utility.internal.SetIterables; import org.eclipse.collections.impl.utility.internal.SetIterate; @@ -159,7 +159,7 @@ public MutableSet collect(Function function) @Override public MutableBooleanSet collectBoolean(BooleanFunction booleanFunction) { - MutableBooleanSet result = new BooleanHashSet(); + MutableBooleanSet result = BooleanSets.mutable.empty(); this.forEach(new CollectBooleanProcedure<>(booleanFunction, result)); return result; } @@ -167,7 +167,7 @@ public MutableBooleanSet collectBoolean(BooleanFunction booleanFuncti @Override public MutableByteSet collectByte(ByteFunction byteFunction) { - MutableByteSet result = new ByteHashSet(); + MutableByteSet result = ByteSets.mutable.empty(); this.forEach(new CollectByteProcedure<>(byteFunction, result)); return result; } @@ -175,7 +175,7 @@ public MutableByteSet collectByte(ByteFunction byteFunction) @Override public MutableCharSet collectChar(CharFunction charFunction) { - MutableCharSet result = new CharHashSet(this.size()); + MutableCharSet result = CharSets.mutable.empty(); this.forEach(new CollectCharProcedure<>(charFunction, result)); return result; } @@ -183,7 +183,7 @@ public MutableCharSet collectChar(CharFunction charFunction) @Override public MutableDoubleSet collectDouble(DoubleFunction doubleFunction) { - MutableDoubleSet result = new DoubleHashSet(this.size()); + MutableDoubleSet result = DoubleSets.mutable.empty(); this.forEach(new CollectDoubleProcedure<>(doubleFunction, result)); return result; } @@ -191,7 +191,7 @@ public MutableDoubleSet collectDouble(DoubleFunction doubleFunction) @Override public MutableFloatSet collectFloat(FloatFunction floatFunction) { - MutableFloatSet result = new FloatHashSet(this.size()); + MutableFloatSet result = FloatSets.mutable.empty(); this.forEach(new CollectFloatProcedure<>(floatFunction, result)); return result; } @@ -199,7 +199,7 @@ public MutableFloatSet collectFloat(FloatFunction floatFunction) @Override public MutableIntSet collectInt(IntFunction intFunction) { - MutableIntSet result = new IntHashSet(this.size()); + MutableIntSet result = IntSets.mutable.empty(); this.forEach(new CollectIntProcedure<>(intFunction, result)); return result; } @@ -207,7 +207,7 @@ public MutableIntSet collectInt(IntFunction intFunction) @Override public MutableLongSet collectLong(LongFunction longFunction) { - MutableLongSet result = new LongHashSet(this.size()); + MutableLongSet result = LongSets.mutable.empty(); this.forEach(new CollectLongProcedure<>(longFunction, result)); return result; } @@ -215,7 +215,7 @@ public MutableLongSet collectLong(LongFunction longFunction) @Override public MutableShortSet collectShort(ShortFunction shortFunction) { - MutableShortSet result = new ShortHashSet(this.size()); + MutableShortSet result = ShortSets.mutable.empty(); this.forEach(new CollectShortProcedure<>(shortFunction, result)); return result; } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/SetAdapter.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/SetAdapter.java index c9abbc5a4a..0a1b62ae31 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/SetAdapter.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/set/mutable/SetAdapter.java @@ -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. @@ -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.factory.Sets; +import org.eclipse.collections.api.factory.primitive.BooleanSets; +import org.eclipse.collections.api.factory.primitive.ByteSets; +import org.eclipse.collections.api.factory.primitive.CharSets; +import org.eclipse.collections.api.factory.primitive.DoubleSets; +import org.eclipse.collections.api.factory.primitive.FloatSets; +import org.eclipse.collections.api.factory.primitive.IntSets; +import org.eclipse.collections.api.factory.primitive.LongSets; +import org.eclipse.collections.api.factory.primitive.ShortSets; import org.eclipse.collections.api.ordered.OrderedIterable; import org.eclipse.collections.api.partition.set.PartitionMutableSet; import org.eclipse.collections.api.set.ImmutableSet; @@ -63,14 +71,6 @@ import org.eclipse.collections.impl.lazy.parallel.set.NonParallelUnsortedSetIterable; import org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap; import org.eclipse.collections.impl.partition.set.PartitionUnifiedSet; -import org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.CharHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.DoubleHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.FloatHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; -import org.eclipse.collections.impl.set.mutable.primitive.ShortHashSet; import org.eclipse.collections.impl.utility.ArrayIterate; import org.eclipse.collections.impl.utility.Iterate; import org.eclipse.collections.impl.utility.internal.SetIterables; @@ -272,7 +272,7 @@ public MutableSet collect(Function function) @Override public MutableBooleanSet collectBoolean(BooleanFunction booleanFunction) { - BooleanHashSet result = new BooleanHashSet(); + MutableBooleanSet result = BooleanSets.mutable.empty(); this.forEach(new CollectBooleanProcedure<>(booleanFunction, result)); return result; } @@ -280,7 +280,7 @@ public MutableBooleanSet collectBoolean(BooleanFunction booleanFuncti @Override public MutableByteSet collectByte(ByteFunction byteFunction) { - ByteHashSet result = new ByteHashSet(this.size()); + MutableByteSet result = ByteSets.mutable.empty(); this.forEach(new CollectByteProcedure<>(byteFunction, result)); return result; } @@ -288,7 +288,7 @@ public MutableByteSet collectByte(ByteFunction byteFunction) @Override public MutableCharSet collectChar(CharFunction charFunction) { - CharHashSet result = new CharHashSet(this.size()); + MutableCharSet result = CharSets.mutable.empty(); this.forEach(new CollectCharProcedure<>(charFunction, result)); return result; } @@ -296,7 +296,7 @@ public MutableCharSet collectChar(CharFunction charFunction) @Override public MutableDoubleSet collectDouble(DoubleFunction doubleFunction) { - DoubleHashSet result = new DoubleHashSet(this.size()); + MutableDoubleSet result = DoubleSets.mutable.empty(); this.forEach(new CollectDoubleProcedure<>(doubleFunction, result)); return result; } @@ -304,7 +304,7 @@ public MutableDoubleSet collectDouble(DoubleFunction doubleFunction) @Override public MutableFloatSet collectFloat(FloatFunction floatFunction) { - FloatHashSet result = new FloatHashSet(this.size()); + MutableFloatSet result = FloatSets.mutable.empty(); this.forEach(new CollectFloatProcedure<>(floatFunction, result)); return result; } @@ -312,7 +312,7 @@ public MutableFloatSet collectFloat(FloatFunction floatFunction) @Override public MutableIntSet collectInt(IntFunction intFunction) { - IntHashSet result = new IntHashSet(this.size()); + MutableIntSet result = IntSets.mutable.empty(); this.forEach(new CollectIntProcedure<>(intFunction, result)); return result; } @@ -320,7 +320,7 @@ public MutableIntSet collectInt(IntFunction intFunction) @Override public MutableLongSet collectLong(LongFunction longFunction) { - LongHashSet result = new LongHashSet(this.size()); + MutableLongSet result = LongSets.mutable.empty(); this.forEach(new CollectLongProcedure<>(longFunction, result)); return result; } @@ -328,7 +328,7 @@ public MutableLongSet collectLong(LongFunction longFunction) @Override public MutableShortSet collectShort(ShortFunction shortFunction) { - ShortHashSet result = new ShortHashSet(this.size()); + MutableShortSet result = ShortSets.mutable.empty(); this.forEach(new CollectShortProcedure<>(shortFunction, result)); return result; }