Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use interfaces instead of implementations where possible without breaking backward compatibility. #1711

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public <S> ImmutableBag<Pair<T, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
HashBag<Pair<T, S>> target = HashBag.newBag(Math.min(this.size(), thatSize));
MutableBag<Pair<T, S>> target = HashBag.newBag(Math.min(this.size(), thatSize));
return this.zip(that, target).toImmutable();
}
return this.zip(that, HashBag.newBag()).toImmutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ImmutableBag<T> newWith(T element)
@Override
public ImmutableBag<T> newWithout(T element)
{
HashBag<T> hashBag = HashBag.newBag(this.delegate);
MutableBag<T> hashBag = HashBag.newBag(this.delegate);
hashBag.remove(element);
return hashBag.toImmutable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public <S> MutableBag<Pair<T, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
HashBag<Pair<T, S>> target = HashBag.newBag(Math.min(this.size(), thatSize));
MutableBag<Pair<T, S>> target = HashBag.newBag(Math.min(this.size(), thatSize));
return this.zip(that, target);
}
return this.zip(that, HashBag.newBag());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone)
@Override
public <V> MutableBag<V> collect(BooleanToObjectFunction<? extends V> function)
{
HashBag<V> result = HashBag.newBag();
MutableBag<V> result = HashBag.newBag();
if (this.containsFalse())
{
result.addOccurrences(function.valueOf(false), this.falseCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.eclipse.collections.api.partition.bag.sorted.PartitionImmutableSortedBag;
import org.eclipse.collections.api.partition.bag.sorted.PartitionMutableSortedBag;
import org.eclipse.collections.api.set.sorted.ImmutableSortedSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.api.tuple.primitive.ObjectIntPair;
import org.eclipse.collections.impl.bag.immutable.AbstractImmutableBagIterable;
Expand Down Expand Up @@ -375,7 +376,7 @@ public ImmutableSortedSet<Pair<T, Integer>> zipWithIndex()
Comparator<? super T> comparator = this.comparator() == null
? Comparators.naturalOrder()
: this.comparator();
TreeSortedSet<Pair<T, Integer>> pairs = TreeSortedSet.newSet(
MutableSortedSet<Pair<T, Integer>> pairs = TreeSortedSet.newSet(
Comparators.<Pair<T, Integer>>chain(
Comparators.byFunction(Functions.firstOfPair(), comparator),
Comparators.byFunction(Functions.secondOfPair())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public <S> MutableList<Pair<T, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
FastList<Pair<T, S>> target = FastList.newList(Math.min(this.size(), thatSize));
MutableList<Pair<T, S>> target = FastList.newList(Math.min(this.size(), thatSize));
return this.zip(that, target);
}
return this.zip(that, FastList.newList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public <S> ImmutableSet<Pair<V, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
UnifiedSet<Pair<V, S>> target = UnifiedSet.newSet(Math.min(this.size(), thatSize));
MutableSet<Pair<V, S>> target = UnifiedSet.newSet(Math.min(this.size(), thatSize));
return this.delegate.zip(that, target).toImmutable();
}
return this.delegate.zip(that, Sets.mutable.empty()).toImmutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public <S> MutableSet<Pair<V, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
UnifiedSet<Pair<V, S>> target = UnifiedSet.newSet(Math.min(this.size(), thatSize));
MutableSet<Pair<V, S>> target = UnifiedSet.newSet(Math.min(this.size(), thatSize));
return this.delegate.zip(that, target);
}
return this.delegate.zip(that, Sets.mutable.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ public <K, V> MutableMap<K, V> toMap(
Function<? super T, ? extends K> keyFunction,
Function<? super T, ? extends V> valueFunction)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this.size());
MutableMap<K, V> map = UnifiedMap.newMap(this.size());
map.collectKeysAndValues(this.getDelegate(), keyFunction, valueFunction);
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ public <E> E[] toArray(E[] array)
@Override
public MutableList<T> toList()
{
Function<Batch<T>, FastList<T>> map = batch -> {
FastList<T> list = FastList.newList();
Function<Batch<T>, MutableList<T>> map = batch -> {
MutableList<T> list = FastList.newList();
batch.forEach(CollectionAddProcedure.on(list));
return list;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public int lastIndexOf(Object object)
@Override
public MutableList<Integer> toList()
{
FastList<Integer> list = FastList.newList(this.size());
MutableList<Integer> list = FastList.newList(this.size());
this.forEach(CollectionAddProcedure.on(list));
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public ImmutableList<T> newWithAll(Iterable<? extends T> elements)
@Override
public ImmutableList<T> newWithoutAll(Iterable<? extends T> elements)
{
FastList<T> result = FastList.newListWith((T[]) this.toArray());
MutableList<T> result = FastList.newListWith((T[]) this.toArray());
this.removeAllFrom(elements, result);
return result.toImmutable();
}
Expand Down Expand Up @@ -289,7 +289,7 @@ public <P> PartitionImmutableList<T> partitionWith(Predicate2<? super T, ? super
@Override
public <S> ImmutableList<S> selectInstancesOf(Class<S> clazz)
{
FastList<S> result = FastList.newList(this.size());
MutableList<S> result = FastList.newList(this.size());
this.forEach(new SelectInstancesOfProcedure<>(clazz, result));
return result.toImmutable();
}
Expand Down Expand Up @@ -778,7 +778,7 @@ public <S> ImmutableList<Pair<T, S>> zip(Iterable<S> that)
if (that instanceof Collection || that instanceof RichIterable)
{
int thatSize = Iterate.sizeOf(that);
FastList<Pair<T, S>> target = FastList.newList(Math.min(this.size(), thatSize));
MutableList<Pair<T, S>> target = FastList.newList(Math.min(this.size(), thatSize));
return this.zip(that, target).toImmutable();
}
return this.zip(that, FastList.newList()).toImmutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone)
@Override
public <V> ImmutableList<V> collect(BooleanToObjectFunction<? extends V> function)
{
FastList<V> target = FastList.newList(this.size);
MutableList<V> target = FastList.newList(this.size);
for (int i = 0; i < this.size; i++)
{
target.add(function.valueOf(this.items.get(i)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ private final class CompositeIterator
private Iterator<E> currentIterator;
private int currentIndex;

private CompositeIterator(FastList<FastList<E>> newLists)
private CompositeIterator(MutableList<FastList<E>> newLists)
{
this.iterators = new Iterator[newLists.size()];
for (int i = 0; i < newLists.size(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone)
@Override
public <V> MutableList<V> collect(BooleanToObjectFunction<? extends V> function)
{
FastList<V> target = FastList.newList(this.size);
MutableList<V> target = FastList.newList(this.size);
for (int i = 0; i < this.size; i++)
{
target.add(function.valueOf(this.items.get(i)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public Set<Entry<K, V>> entrySet()
@Override
public ImmutableMap<K, V> newWithKeyValue(K key, V value)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this);
MutableMap<K, V> map = UnifiedMap.newMap(this);
map.put(key, value);
return map.toImmutable();
}

@Override
public ImmutableMap<K, V> newWithAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this);
MutableMap<K, V> map = UnifiedMap.newMap(this);
for (Pair<? extends K, ? extends V> keyValuePair : keyValues)
{
map.put(keyValuePair.getOne(), keyValuePair.getTwo());
Expand All @@ -181,7 +181,7 @@ public ImmutableMap<K, V> newWithMapIterable(MapIterable<? extends K, ? extends
@Override
public ImmutableMap<K, V> newWithAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this);
MutableMap<K, V> map = UnifiedMap.newMap(this);
for (Pair<? extends K, ? extends V> keyValuePair : keyValuePairs)
{
map.put(keyValuePair.getOne(), keyValuePair.getTwo());
Expand All @@ -192,15 +192,15 @@ public ImmutableMap<K, V> newWithAllKeyValueArguments(Pair<? extends K, ? extend
@Override
public ImmutableMap<K, V> newWithoutKey(K key)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this);
MutableMap<K, V> map = UnifiedMap.newMap(this);
map.removeKey(key);
return map.toImmutable();
}

@Override
public ImmutableMap<K, V> newWithoutAllKeys(Iterable<? extends K> keys)
{
UnifiedMap<K, V> map = UnifiedMap.newMap(this);
MutableMap<K, V> map = UnifiedMap.newMap(this);
for (K key : keys)
{
map.removeKey(key);
Expand Down Expand Up @@ -229,28 +229,28 @@ public ImmutableMap<V, K> flipUniqueValues()
@Override
public <K2, V2> ImmutableMap<K2, V2> collect(Function2<? super K, ? super V, Pair<K2, V2>> function)
{
UnifiedMap<K2, V2> result = MapIterate.collect(this, function, UnifiedMap.newMap());
MutableMap<K2, V2> result = MapIterate.collect(this, function, UnifiedMap.newMap());
return result.toImmutable();
}

@Override
public <R> ImmutableMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function)
{
UnifiedMap<K, R> result = MapIterate.collectValues(this, function, UnifiedMap.newMap(this.size()));
MutableMap<K, R> result = MapIterate.collectValues(this, function, UnifiedMap.newMap(this.size()));
return result.toImmutable();
}

@Override
public ImmutableMap<K, V> select(Predicate2<? super K, ? super V> predicate)
{
UnifiedMap<K, V> result = MapIterate.selectMapOnEntry(this, predicate, UnifiedMap.newMap());
MutableMap<K, V> result = MapIterate.selectMapOnEntry(this, predicate, UnifiedMap.newMap());
return result.toImmutable();
}

@Override
public ImmutableMap<K, V> reject(Predicate2<? super K, ? super V> predicate)
{
UnifiedMap<K, V> result = MapIterate.rejectMapOnEntry(this, predicate, UnifiedMap.newMap());
MutableMap<K, V> result = MapIterate.rejectMapOnEntry(this, predicate, UnifiedMap.newMap());
return result.toImmutable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.factory.Sets;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.UnsortedMapIterable;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.block.factory.Functions;
import org.eclipse.collections.impl.block.factory.Predicates;
Expand Down Expand Up @@ -2474,7 +2476,7 @@ public <T> T[] toArray(T[] result)

protected Object writeReplace()
{
UnifiedSet<K> replace = UnifiedSet.newSet(UnifiedMap.this.size());
MutableSet<K> replace = UnifiedSet.newSet(UnifiedMap.this.size());
for (int i = 0; i < UnifiedMap.this.table.length; i += 2)
{
Object cur = UnifiedMap.this.table[i];
Expand All @@ -2490,7 +2492,7 @@ else if (cur != null)
return replace;
}

private void chainedAddToSet(Object[] chain, UnifiedSet<K> replace)
private void chainedAddToSet(Object[] chain, MutableSet<K> replace)
{
for (int i = 0; i < chain.length; i += 2)
{
Expand Down Expand Up @@ -3304,7 +3306,7 @@ public <T> T[] toArray(T[] result)

protected Object writeReplace()
{
FastList<V> replace = FastList.newList(UnifiedMap.this.size());
MutableList<V> replace = FastList.newList(UnifiedMap.this.size());
for (int i = 0; i < UnifiedMap.this.table.length; i += 2)
{
Object cur = UnifiedMap.this.table[i];
Expand All @@ -3320,7 +3322,7 @@ else if (cur != null)
return replace;
}

private void chainedAddToList(Object[] chain, FastList<V> replace)
private void chainedAddToList(Object[] chain, MutableList<V> replace)
{
for (int i = 0; i < chain.length; i += 2)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.eclipse.collections.api.factory.primitive.ObjectLongMaps;
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.primitive.ImmutableBooleanList;
import org.eclipse.collections.api.list.primitive.ImmutableByteList;
import org.eclipse.collections.api.list.primitive.ImmutableCharList;
Expand Down Expand Up @@ -300,7 +301,7 @@ public <P> PartitionImmutableList<V> partitionWith(Predicate2<? super V, ? super
@Override
public <S> ImmutableList<S> selectInstancesOf(Class<S> clazz)
{
FastList<S> result = FastList.newList(this.size());
MutableList<S> result = FastList.newList(this.size());
this.forEach(new SelectInstancesOfProcedure<>(clazz, result));
return result.toImmutable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ public <P> void forEachWith(Procedure2<? super V, ? super P> procedure, P parame
@Override
public ImmutableMap<K, V> newWithKeyValue(K key, V value)
{
UnifiedMapWithHashingStrategy<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
MutableMap<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
result.put(key, value);
return result.toImmutable();
}

@Override
public ImmutableMap<K, V> newWithAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)
{
UnifiedMapWithHashingStrategy<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
MutableMap<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
for (Pair<? extends K, ? extends V> pair : keyValues)
{
result.put(pair.getOne(), pair.getTwo());
Expand All @@ -218,7 +218,7 @@ public ImmutableMap<K, V> newWithMapIterable(MapIterable<? extends K, ? extends
@Override
public ImmutableMap<K, V> newWithAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs)
{
UnifiedMapWithHashingStrategy<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
MutableMap<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
for (Pair<? extends K, ? extends V> keyValuePair : keyValuePairs)
{
result.put(keyValuePair.getOne(), keyValuePair.getTwo());
Expand All @@ -229,15 +229,15 @@ public ImmutableMap<K, V> newWithAllKeyValueArguments(Pair<? extends K, ? extend
@Override
public ImmutableMap<K, V> newWithoutKey(K key)
{
UnifiedMapWithHashingStrategy<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
MutableMap<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
result.remove(key);
return result.toImmutable();
}

@Override
public ImmutableMap<K, V> newWithoutAllKeys(Iterable<? extends K> keys)
{
UnifiedMapWithHashingStrategy<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
MutableMap<K, V> result = UnifiedMapWithHashingStrategy.newMap(this.delegate);
for (K key : keys)
{
result.remove(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.factory.Sets;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.ImmutableMap;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.UnsortedMapIterable;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.block.factory.Functions;
import org.eclipse.collections.impl.block.factory.Predicates;
Expand Down Expand Up @@ -2532,7 +2534,7 @@ public <T> T[] toArray(T[] result)

protected Object writeReplace()
{
UnifiedSetWithHashingStrategy<K> replace = UnifiedSetWithHashingStrategy.newSet(
MutableSet<K> replace = UnifiedSetWithHashingStrategy.newSet(
UnifiedMapWithHashingStrategy.this.hashingStrategy, UnifiedMapWithHashingStrategy.this.size());
for (int i = 0; i < UnifiedMapWithHashingStrategy.this.table.length; i += 2)
{
Expand All @@ -2549,7 +2551,7 @@ else if (cur != null)
return replace;
}

private void chainedAddToSet(Object[] chain, UnifiedSetWithHashingStrategy<K> replace)
private void chainedAddToSet(Object[] chain, MutableSet<K> replace)
{
for (int i = 0; i < chain.length; i += 2)
{
Expand Down Expand Up @@ -3373,7 +3375,7 @@ public <T> T[] toArray(T[] result)

protected Object writeReplace()
{
FastList<V> replace = FastList.newList(UnifiedMapWithHashingStrategy.this.size());
MutableList<V> replace = FastList.newList(UnifiedMapWithHashingStrategy.this.size());
for (int i = 0; i < UnifiedMapWithHashingStrategy.this.table.length; i += 2)
{
Object cur = UnifiedMapWithHashingStrategy.this.table[i];
Expand All @@ -3389,7 +3391,7 @@ else if (cur != null)
return replace;
}

private void chainedAddToList(Object[] chain, FastList<V> replace)
private void chainedAddToList(Object[] chain, MutableList<V> replace)
{
for (int i = 0; i < chain.length; i += 2)
{
Expand Down
Loading