package org.eclipse.collections.impl.list.mutable.primitive;
import java.util.Collection;
import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.LazyLongIterable;
import org.eclipse.collections.api.block.function.primitive.LongIntToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.LongToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.ObjectLongIntToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.LongPredicate;
import org.eclipse.collections.api.block.procedure.primitive.LongIntProcedure;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.LongList;
import org.eclipse.collections.api.list.primitive.ImmutableLongList;
import org.eclipse.collections.api.list.primitive.MutableLongList;
import org.eclipse.collections.api.tuple.primitive.LongLongPair;
import org.eclipse.collections.api.tuple.primitive.LongObjectPair;
import org.eclipse.collections.impl.collection.mutable.primitive.AbstractSynchronizedLongCollection;
import org.eclipse.collections.impl.factory.primitive.LongLists;
import org.eclipse.collections.impl.lazy.primitive.LazyLongIterableAdapter;
import org.eclipse.collections.impl.lazy.primitive.ReverseLongIterable;
import java.util.Spliterator;
public class SynchronizedLongList
extends AbstractSynchronizedLongCollection
implements MutableLongList
{
private static final long serialVersionUID = 1L;
public SynchronizedLongList(MutableLongList list)
{
super(list);
}
public SynchronizedLongList(MutableLongList list, Object newLock)
{
super(list, newLock);
}
private MutableLongList getMutableLongList()
{
return (MutableLongList) this.getLongCollection();
}
@Override
public long get(int index)
{
synchronized (this.getLock())
{
return this.getMutableLongList().get(index);
}
}
@Override
public long getFirst()
{
synchronized (this.getLock())
{
return this.getMutableLongList().getFirst();
}
}
@Override
public long getLast()
{
synchronized (this.getLock())
{
return this.getMutableLongList().getLast();
}
}
@Override
public int indexOf(long value)
{
synchronized (this.getLock())
{
return this.getMutableLongList().indexOf(value);
}
}
@Override
public int lastIndexOf(long value)
{
synchronized (this.getLock())
{
return this.getMutableLongList().lastIndexOf(value);
}
}
@Override
public void addAtIndex(int index, long element)
{
synchronized (this.getLock())
{
this.getMutableLongList().addAtIndex(index, element);
}
}
@Override
public boolean addAllAtIndex(int index, long... source)
{
synchronized (this.getLock())
{
return this.getMutableLongList().addAllAtIndex(index, source);
}
}
@Override
public boolean addAllAtIndex(int index, LongIterable source)
{
synchronized (this.getLock())
{
return this.getMutableLongList().addAllAtIndex(index, source);
}
}
@Override
public long removeAtIndex(int index)
{
synchronized (this.getLock())
{
return this.getMutableLongList().removeAtIndex(index);
}
}
@Override
public long set(int index, long element)
{
synchronized (this.getLock())
{
return this.getMutableLongList().set(index, element);
}
}
@Override
public SynchronizedLongList with(long element)
{
synchronized (this.getLock())
{
this.getMutableLongList().add(element);
}
return this;
}
@Override
public SynchronizedLongList without(long element)
{
synchronized (this.getLock())
{
this.getMutableLongList().remove(element);
}
return this;
}
@Override
public SynchronizedLongList withAll(LongIterable elements)
{
synchronized (this.getLock())
{
this.getMutableLongList().addAll(elements.toArray());
}
return this;
}
@Override
public SynchronizedLongList withoutAll(LongIterable elements)
{
synchronized (this.getLock())
{
this.getMutableLongList().removeAll(elements);
}
return this;
}
@Override
public MutableLongList select(LongPredicate predicate)
{
synchronized (this.getLock())
{
return this.getMutableLongList().select(predicate);
}
}
@Override
public MutableLongList reject(LongPredicate predicate)
{
synchronized (this.getLock())
{
return this.getMutableLongList().reject(predicate);
}
}
@Override
public <V> MutableList<V> collect(LongToObjectFunction<? extends V> function)
{
synchronized (this.getLock())
{
return this.getMutableLongList().collect(function);
}
}
@Override
public MutableLongList sortThis()
{
synchronized (this.getLock())
{
this.getMutableLongList().sortThis();
}
return this;
}
@Override
public int binarySearch(long value)
{
synchronized (this.getLock())
{
return this.getMutableLongList().binarySearch(value);
}
}
@Override
public long dotProduct(LongList list)
{
synchronized (this.getLock())
{
return this.getMutableLongList().dotProduct(list);
}
}
@Override
public boolean equals(Object otherList)
{
synchronized (this.getLock())
{
return this.getMutableLongList().equals(otherList);
}
}
@Override
public int hashCode()
{
synchronized (this.getLock())
{
return this.getMutableLongList().hashCode();
}
}
@Override
public LazyLongIterable asLazy()
{
synchronized (this.getLock())
{
return new LazyLongIterableAdapter(this);
}
}
@Override
public MutableLongList asUnmodifiable()
{
synchronized (this.getLock())
{
return new UnmodifiableLongList(this);
}
}
@Override
public MutableLongList asSynchronized()
{
return this;
}
@Override
public ImmutableLongList toImmutable()
{
synchronized (this.getLock())
{
int size = this.size();
if (size == 0)
{
return LongLists.immutable.with();
}
if (size == 1)
{
return LongLists.immutable.with(this.getFirst());
}
return LongLists.immutable.with(this.toArray());
}
}
public MutableLongList newEmpty()
{
synchronized (this.getLock())
{
return this.getMutableLongList().newEmpty();
}
}
@Override
public MutableLongList reverseThis()
{
synchronized (this.getLock())
{
this.getMutableLongList().reverseThis();
}
return this;
}
@Override
public MutableLongList toReversed()
{
synchronized (this.getLock())
{
return this.getMutableLongList().toReversed();
}
}
@Override
public LazyLongIterable asReversed()
{
return ReverseLongIterable.adapt(this);
}
@Override
public void forEachWithIndex(LongIntProcedure procedure)
{
synchronized (this.getLock())
{
this.getMutableLongList().forEachWithIndex(procedure);
}
}
@Override
public <T> T injectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T, ? extends T> function)
{
synchronized (this.getLock())
{
return this.getMutableLongList().injectIntoWithIndex(injectedValue, function);
}
}
@Override
public MutableLongList distinct()
{
synchronized (this.getLock())
{
return this.getMutableLongList().distinct();
}
}
@Override
public MutableLongList subList(int fromIndex, int toIndex)
{
throw new UnsupportedOperationException("subList not yet implemented!");
}
public MutableList<LongLongPair> zipLong(LongIterable iterable)
{
synchronized (this.getLock())
{
return this.getMutableLongList().zipLong(iterable);
}
}
public <T> MutableList<LongObjectPair<T>> zip(Iterable<T> iterable)
{
synchronized (this.getLock())
{
return this.getMutableLongList().zip(iterable);
}
}
@Override
public <V> MutableList<V> collectWithIndex(LongIntToObjectFunction<? extends V> function)
{
synchronized (this.getLock())
{
return this.getMutableLongList().collectWithIndex(function);
}
}
public <V, R extends Collection<V>> R collectWithIndex(LongIntToObjectFunction<? extends V> function, R target)
{
synchronized (this.getLock())
{
return this.getMutableLongList().collectWithIndex(function, target);
}
}
@Override
public Spliterator.OfLong spliterator()
{
return this.getMutableLongList().spliterator();
}
}