package org.eclipse.collections.impl.primitive;
import java.io.Serializable;
import org.eclipse.collections.api.DoubleIterable;
import org.eclipse.collections.api.LazyDoubleIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.bag.primitive.MutableDoubleBag;
import org.eclipse.collections.api.block.function.primitive.DoubleDoubleToDoubleFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.ObjectDoubleToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.DoublePredicate;
import org.eclipse.collections.api.block.procedure.primitive.DoubleProcedure;
import org.eclipse.collections.api.iterator.DoubleIterator;
import org.eclipse.collections.api.list.primitive.MutableDoubleList;
import org.eclipse.collections.api.set.primitive.MutableDoubleSet;
public class SynchronizedDoubleIterable implements DoubleIterable, Serializable
{
private static final long serialVersionUID = 1L;
private final Object lock;
private final DoubleIterable iterable;
protected SynchronizedDoubleIterable(DoubleIterable iterable)
{
this(iterable, null);
}
protected SynchronizedDoubleIterable(DoubleIterable iterable, Object newLock)
{
if (iterable == null)
{
throw new IllegalArgumentException("Cannot create a SynchronizedDoubleIterable on a null collection");
}
this.iterable = iterable;
this.lock = newLock == null ? this : newLock;
}
public static SynchronizedDoubleIterable of(DoubleIterable iterable)
{
return new SynchronizedDoubleIterable(iterable);
}
public static SynchronizedDoubleIterable of(DoubleIterable iterable, Object lock)
{
return new SynchronizedDoubleIterable(iterable, lock);
}
@Override
public double[] toArray()
{
synchronized (this.lock)
{
return this.iterable.toArray();
}
}
@Override
public double[] toArray(double[] target)
{
synchronized (this.lock)
{
return this.iterable.toArray(target);
}
}
@Override
public boolean contains(double value)
{
synchronized (this.lock)
{
return this.iterable.contains(value);
}
}
@Override
public boolean containsAll(double... source)
{
synchronized (this.lock)
{
return this.iterable.containsAll(source);
}
}
@Override
public boolean containsAll(DoubleIterable source)
{
synchronized (this.lock)
{
return this.iterable.containsAll(source);
}
}
@Override
public boolean containsAny(double... source)
{
synchronized (this.lock)
{
return this.iterable.containsAny(source);
}
}
@Override
public boolean containsAny(DoubleIterable source)
{
synchronized (this.lock)
{
return this.iterable.containsAny(source);
}
}
@Override
public boolean containsNone(double... source)
{
synchronized (this.lock)
{
return this.iterable.containsNone(source);
}
}
@Override
public boolean containsNone(DoubleIterable source)
{
synchronized (this.lock)
{
return this.iterable.containsNone(source);
}
}
@Override
public void forEach(DoubleProcedure procedure)
{
this.each(procedure);
}
@Override
public void each(DoubleProcedure procedure)
{
synchronized (this.lock)
{
this.iterable.forEach(procedure);
}
}
@Override
public DoubleIterable select(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.select(predicate);
}
}
@Override
public DoubleIterable reject(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.reject(predicate);
}
}
@Override
public <V> RichIterable<V> collect(DoubleToObjectFunction<? extends V> function)
{
synchronized (this.lock)
{
return this.iterable.collect(function);
}
}
@Override
public double detectIfNone(DoublePredicate predicate, double ifNone)
{
synchronized (this.lock)
{
return this.iterable.detectIfNone(predicate, ifNone);
}
}
@Override
public int count(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.count(predicate);
}
}
@Override
public boolean anySatisfy(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.anySatisfy(predicate);
}
}
@Override
public boolean allSatisfy(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.allSatisfy(predicate);
}
}
@Override
public boolean noneSatisfy(DoublePredicate predicate)
{
synchronized (this.lock)
{
return this.iterable.noneSatisfy(predicate);
}
}
@Override
public MutableDoubleList toList()
{
synchronized (this.lock)
{
return this.iterable.toList();
}
}
@Override
public MutableDoubleSet toSet()
{
synchronized (this.lock)
{
return this.iterable.toSet();
}
}
@Override
public MutableDoubleBag toBag()
{
synchronized (this.lock)
{
return this.iterable.toBag();
}
}
@Override
public LazyDoubleIterable asLazy()
{
synchronized (this.lock)
{
return this.iterable.asLazy();
}
}
@Override
public double sum()
{
synchronized (this.lock)
{
return this.iterable.sum();
}
}
@Override
public double max()
{
synchronized (this.lock)
{
return this.iterable.max();
}
}
@Override
public double maxIfEmpty(double defaultValue)
{
synchronized (this.lock)
{
return this.iterable.maxIfEmpty(defaultValue);
}
}
@Override
public double min()
{
synchronized (this.lock)
{
return this.iterable.min();
}
}
@Override
public double minIfEmpty(double defaultValue)
{
synchronized (this.lock)
{
return this.iterable.minIfEmpty(defaultValue);
}
}
@Override
public double average()
{
synchronized (this.lock)
{
return this.iterable.average();
}
}
@Override
public double median()
{
synchronized (this.lock)
{
return this.iterable.median();
}
}
@Override
public double[] toSortedArray()
{
synchronized (this.lock)
{
return this.iterable.toSortedArray();
}
}
@Override
public MutableDoubleList toSortedList()
{
synchronized (this.lock)
{
return this.iterable.toSortedList();
}
}
@Override
public int size()
{
synchronized (this.lock)
{
return this.iterable.size();
}
}
@Override
public boolean isEmpty()
{
synchronized (this.lock)
{
return this.iterable.isEmpty();
}
}
@Override
public boolean notEmpty()
{
synchronized (this.lock)
{
return this.iterable.notEmpty();
}
}
@Override
public <T> T injectInto(T injectedValue, ObjectDoubleToObjectFunction<? super T, ? extends T> function)
{
synchronized (this.lock)
{
return this.iterable.injectInto(injectedValue, function);
}
}
@Override
public double reduce(DoubleDoubleToDoubleFunction accumulator)
{
synchronized (this.lock)
{
return this.iterable.reduce(accumulator);
}
}
@Override
public double reduceIfEmpty(DoubleDoubleToDoubleFunction accumulator, double defaultValue)
{
synchronized (this.lock)
{
return this.iterable.reduceIfEmpty(accumulator, defaultValue);
}
}
@Override
public RichIterable<DoubleIterable> chunk(int size)
{
synchronized (this.lock)
{
return this.iterable.chunk(size);
}
}
@Override
public String toString()
{
synchronized (this.lock)
{
return this.iterable.toString();
}
}
@Override
public String makeString()
{
synchronized (this.lock)
{
return this.iterable.makeString();
}
}
@Override
public String makeString(String separator)
{
synchronized (this.lock)
{
return this.iterable.makeString(separator);
}
}
@Override
public String makeString(String start, String separator, String end)
{
synchronized (this.lock)
{
return this.iterable.makeString(start, separator, end);
}
}
@Override
public void appendString(Appendable appendable)
{
synchronized (this.lock)
{
this.iterable.appendString(appendable);
}
}
@Override
public void appendString(Appendable appendable, String separator)
{
synchronized (this.lock)
{
this.iterable.appendString(appendable, separator);
}
}
@Override
public void appendString(Appendable appendable, String start, String separator, String end)
{
synchronized (this.lock)
{
this.iterable.appendString(appendable, start, separator, end);
}
}
@Override
public DoubleIterator doubleIterator()
{
return this.iterable.doubleIterator();
}
}