select(Predicate super T> 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 super T, ? super P> 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 super T> 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 super T, ? super P> 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 super T, ? extends Iterable 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 super S> comparator = (Comparator super S>) 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 super T, ? extends V
@Override
public ImmutableSortedBag takeWhile(Predicate super T> 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 super T> predicate)
@Override
public ImmutableSortedBag dropWhile(Predicate super T> 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 super S> comparator = (Comparator super S>) 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 super T> 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 super T> 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 super T, ? extends Iterable>
@Override
public MutableSortedBag select(Predicate super T> predicate)
{
- return this.select(predicate, TreeBag.newBag(this.comparator()));
+ return this.select(predicate, SortedBags.mutable.empty(this.comparator()));
}
@Override
public MutableSortedBag selectWith(Predicate2 super T, ? super P> 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 super T> predicate)
{
- return this.reject(predicate, TreeBag.newBag(this.comparator()));
+ return this.reject(predicate, SortedBags.mutable.empty(this.comparator()));
}
@Override
public MutableSortedBag rejectWith(Predicate2 super T, ? super P> 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 super T> comparator)
{
+ //noinspection SSBasedInspection
return TreeBag.newBag(comparator);
}
@@ -52,6 +53,7 @@ public MutableSortedBag of(Comparator super T> comparator)
@Override
public MutableSortedBag with(Comparator super T> 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 super T> comparator)
{
- MutableSortedBag result = TreeBag.newBag(comparator);
+ MutableSortedBag result = SortedBags.mutable.empty(comparator);
result = result.asSynchronized();
this.forEach(CollectionAddProcedure.on(result));
return result;