diff --git a/.idea/inspectionProfiles/IDE.xml b/.idea/inspectionProfiles/IDE.xml index b60462fbde..3a11912bcd 100644 --- a/.idea/inspectionProfiles/IDE.xml +++ b/.idea/inspectionProfiles/IDE.xml @@ -656,6 +656,10 @@ + + + + diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/AbstractRichIterable.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/AbstractRichIterable.java index 180f4f46f4..274e0df77c 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/AbstractRichIterable.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/AbstractRichIterable.java @@ -43,6 +43,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.SortedBags; import org.eclipse.collections.api.factory.SortedMaps; import org.eclipse.collections.api.factory.SortedSets; import org.eclipse.collections.api.list.MutableList; @@ -206,7 +207,7 @@ public MutableSortedBag toSortedBag() @Override public MutableSortedBag toSortedBag(Comparator comparator) { - MutableSortedBag sortedBag = TreeBag.newBag(comparator); + MutableSortedBag sortedBag = SortedBags.mutable.empty(comparator); this.forEachWith(Procedures2.addToCollection(), sortedBag); return sortedBag; } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/AbstractBag.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/AbstractBag.java index 8199769579..f0aed2d941 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/AbstractBag.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/AbstractBag.java @@ -63,6 +63,7 @@ import org.eclipse.collections.api.factory.Bags; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.SortedBags; import org.eclipse.collections.api.factory.SortedSets; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.multimap.MutableMultimap; @@ -938,7 +939,7 @@ public MutableSortedBag toSortedBag() @Override public MutableSortedBag toSortedBag(Comparator comparator) { - MutableSortedBag result = TreeBag.newBag(comparator); + MutableSortedBag result = SortedBags.mutable.empty(comparator); this.forEachWithOccurrences(result::addOccurrences); return result; } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/immutable/ImmutableEmptyBag.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/immutable/ImmutableEmptyBag.java index 279956866e..333c37ec20 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/immutable/ImmutableEmptyBag.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/immutable/ImmutableEmptyBag.java @@ -57,6 +57,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.factory.SortedBags; import org.eclipse.collections.api.factory.primitive.BooleanBags; import org.eclipse.collections.api.factory.primitive.ByteBags; import org.eclipse.collections.api.factory.primitive.CharBags; @@ -605,7 +606,7 @@ public MutableSortedBag toSortedBag() @Override public MutableSortedBag toSortedBag(Comparator comparator) { - return TreeBag.newBag(comparator); + return SortedBags.mutable.empty(comparator); } @Override diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/AbstractImmutableSortedBag.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/AbstractImmutableSortedBag.java index 5445442a7b..68c8c4184a 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/AbstractImmutableSortedBag.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/AbstractImmutableSortedBag.java @@ -38,6 +38,7 @@ import org.eclipse.collections.api.collection.MutableCollection; import org.eclipse.collections.api.factory.Bags; import org.eclipse.collections.api.factory.Lists; +import org.eclipse.collections.api.factory.SortedBags; import org.eclipse.collections.api.factory.Stacks; import org.eclipse.collections.api.factory.primitive.BooleanLists; import org.eclipse.collections.api.factory.primitive.ByteLists; @@ -66,7 +67,6 @@ import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.api.tuple.primitive.ObjectIntPair; import org.eclipse.collections.impl.bag.immutable.AbstractImmutableBagIterable; -import org.eclipse.collections.impl.bag.sorted.mutable.TreeBag; import org.eclipse.collections.impl.block.factory.Comparators; import org.eclipse.collections.impl.block.factory.Functions; import org.eclipse.collections.impl.block.factory.Predicates; @@ -157,25 +157,25 @@ public ImmutableMap groupByUniqueKey(Function @Override public ImmutableSortedBag select(Predicate predicate) { - return this.select(predicate, TreeBag.newBag(this.comparator())).toImmutable(); + return this.select(predicate, SortedBags.mutable.empty(this.comparator())).toImmutable(); } @Override public

ImmutableSortedBag selectWith(Predicate2 predicate, P parameter) { - return this.selectWith(predicate, parameter, TreeBag.newBag(this.comparator())).toImmutable(); + return this.selectWith(predicate, parameter, SortedBags.mutable.empty(this.comparator())).toImmutable(); } @Override public ImmutableSortedBag reject(Predicate predicate) { - return this.reject(predicate, TreeBag.newBag(this.comparator())).toImmutable(); + return this.reject(predicate, SortedBags.mutable.empty(this.comparator())).toImmutable(); } @Override public

ImmutableSortedBag rejectWith(Predicate2 predicate, P parameter) { - return this.rejectWith(predicate, parameter, TreeBag.newBag(this.comparator())).toImmutable(); + return this.rejectWith(predicate, parameter, SortedBags.mutable.empty(this.comparator())).toImmutable(); } @Override @@ -285,7 +285,7 @@ public ImmutableList flatCollect(Function selectByOccurrences(IntPredicate predicate) { - MutableSortedBag result = TreeBag.newBag(this.comparator()); + MutableSortedBag result = SortedBags.mutable.empty(this.comparator()); this.forEachWithOccurrences((each, occurrences) -> { if (predicate.accept(occurrences)) @@ -300,7 +300,7 @@ public ImmutableSortedBag selectByOccurrences(IntPredicate predicate) public ImmutableSortedBag selectInstancesOf(Class clazz) { Comparator comparator = (Comparator) this.comparator(); - MutableSortedBag result = TreeBag.newBag(comparator); + MutableSortedBag result = SortedBags.mutable.empty(comparator); this.forEachWithOccurrences((each, occurrences) -> { if (clazz.isInstance(each)) @@ -434,7 +434,7 @@ public RichIterable> chunk(int size) MutableList> result = Lists.mutable.empty(); T[] objects = (T[]) this.toArray(); - MutableCollection batch = TreeBag.newBag(this.comparator()); + MutableCollection batch = SortedBags.mutable.empty(this.comparator()); int j = 0; while (j < objects.length) diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/ImmutableSortedBagImpl.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/ImmutableSortedBagImpl.java index 2825e13e6a..77dc7a0d9f 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/ImmutableSortedBagImpl.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/immutable/ImmutableSortedBagImpl.java @@ -43,7 +43,6 @@ import org.eclipse.collections.api.set.sorted.ImmutableSortedSet; import org.eclipse.collections.api.set.sorted.MutableSortedSet; import org.eclipse.collections.impl.Counter; -import org.eclipse.collections.impl.bag.sorted.mutable.TreeBag; import org.eclipse.collections.impl.block.factory.Comparators; import org.eclipse.collections.impl.list.fixed.ArrayAdapter; import org.eclipse.collections.impl.list.mutable.FastList; @@ -219,7 +218,7 @@ public > T maxBy(Function takeWhile(Predicate predicate) { - MutableSortedBag bag = TreeBag.newBag(this.comparator); + MutableSortedBag bag = SortedBags.mutable.empty(this.comparator); for (int i = 0; i < this.elements.length; i++) { if (predicate.accept(this.elements[i])) @@ -237,7 +236,7 @@ public ImmutableSortedBag takeWhile(Predicate predicate) @Override public ImmutableSortedBag dropWhile(Predicate predicate) { - MutableSortedBag bag = TreeBag.newBag(this.comparator); + MutableSortedBag bag = SortedBags.mutable.empty(this.comparator); int startIndex = this.detectNotIndex(predicate); for (int i = startIndex; i < this.elements.length; i++) { @@ -708,7 +707,7 @@ public ImmutableSortedBag take(int count) return this; } - MutableSortedBag output = TreeBag.newBag(this.comparator()); + MutableSortedBag output = SortedBags.mutable.empty(this.comparator()); int index = 0; for (int i = 0; i < this.elements.length; i++) { @@ -742,7 +741,7 @@ public ImmutableSortedBag drop(int count) return SortedBags.immutable.empty(this.comparator()); } - MutableSortedBag output = TreeBag.newBag(this.comparator()); + MutableSortedBag output = SortedBags.mutable.empty(this.comparator()); int index = 0; for (int i = 0; i < this.elements.length; i++) { diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/AbstractMutableSortedBag.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/AbstractMutableSortedBag.java index 348004bf08..1993de73f0 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/AbstractMutableSortedBag.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/AbstractMutableSortedBag.java @@ -109,7 +109,7 @@ public MutableSortedMap toMapOfItemToCount() public MutableSortedBag selectInstancesOf(Class clazz) { Comparator comparator = (Comparator) this.comparator(); - MutableSortedBag result = TreeBag.newBag(comparator); + MutableSortedBag result = SortedBags.mutable.empty(comparator); this.forEachWithOccurrences((each, occurrences) -> { if (clazz.isInstance(each)) { @@ -122,14 +122,14 @@ public MutableSortedBag selectInstancesOf(Class clazz) @Override public MutableSortedBag takeWhile(Predicate predicate) { - MutableSortedBag result = TreeBag.newBag(this.comparator()); + MutableSortedBag result = SortedBags.mutable.empty(this.comparator()); return IterableIterate.takeWhile(this, predicate, result); } @Override public MutableSortedBag dropWhile(Predicate predicate) { - MutableSortedBag result = TreeBag.newBag(this.comparator()); + MutableSortedBag result = SortedBags.mutable.empty(this.comparator()); return IterableIterate.dropWhile(this, predicate, result); } @@ -163,25 +163,25 @@ public MutableBag countByEach(Function> @Override public MutableSortedBag select(Predicate predicate) { - return this.select(predicate, TreeBag.newBag(this.comparator())); + return this.select(predicate, SortedBags.mutable.empty(this.comparator())); } @Override public

MutableSortedBag selectWith(Predicate2 predicate, P parameter) { - return this.selectWith(predicate, parameter, TreeBag.newBag(this.comparator())); + return this.selectWith(predicate, parameter, SortedBags.mutable.empty(this.comparator())); } @Override public MutableSortedBag reject(Predicate predicate) { - return this.reject(predicate, TreeBag.newBag(this.comparator())); + return this.reject(predicate, SortedBags.mutable.empty(this.comparator())); } @Override public

MutableSortedBag rejectWith(Predicate2 predicate, P parameter) { - return this.rejectWith(predicate, parameter, TreeBag.newBag(this.comparator())); + return this.rejectWith(predicate, parameter, SortedBags.mutable.empty(this.comparator())); } @Override diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/MutableSortedBagFactoryImpl.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/MutableSortedBagFactoryImpl.java index 2581038d89..0625ed8b16 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/MutableSortedBagFactoryImpl.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/bag/sorted/mutable/MutableSortedBagFactoryImpl.java @@ -28,6 +28,7 @@ public MutableSortedBag empty() @Override public MutableSortedBag empty(Comparator comparator) { + //noinspection SSBasedInspection return TreeBag.newBag(comparator); } @@ -52,6 +53,7 @@ public MutableSortedBag of(Comparator comparator) @Override public MutableSortedBag with(Comparator comparator) { + //noinspection SSBasedInspection return TreeBag.newBag(comparator); } diff --git a/eclipse-collections/src/main/java/org/eclipse/collections/impl/lazy/parallel/AbstractParallelIterable.java b/eclipse-collections/src/main/java/org/eclipse/collections/impl/lazy/parallel/AbstractParallelIterable.java index 5e791c9fd3..4afec05acb 100644 --- a/eclipse-collections/src/main/java/org/eclipse/collections/impl/lazy/parallel/AbstractParallelIterable.java +++ b/eclipse-collections/src/main/java/org/eclipse/collections/impl/lazy/parallel/AbstractParallelIterable.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. @@ -38,6 +38,7 @@ import org.eclipse.collections.api.block.predicate.Predicate2; import org.eclipse.collections.api.block.procedure.Procedure; import org.eclipse.collections.api.block.procedure.Procedure2; +import org.eclipse.collections.api.factory.SortedBags; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.MapIterable; import org.eclipse.collections.api.map.MutableMap; @@ -538,7 +539,7 @@ public MutableSortedBag toSortedBag() @Override public MutableSortedBag toSortedBag(Comparator comparator) { - MutableSortedBag result = TreeBag.newBag(comparator); + MutableSortedBag result = SortedBags.mutable.empty(comparator); result = result.asSynchronized(); this.forEach(CollectionAddProcedure.on(result)); return result;