All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.collections.impl.lazy.parallel.AbstractSynchronizedParallelIterable Maven / Gradle / Ivy

/*
 * Copyright (c) 2015 Goldman Sachs.
 * 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.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 */

package org.eclipse.collections.impl.lazy.parallel;

import java.util.Comparator;

import org.eclipse.collections.api.ParallelIterable;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.sorted.MutableSortedBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
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.list.MutableList;
import org.eclipse.collections.api.list.ParallelListIterable;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.ParallelUnsortedSetIterable;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.set.sorted.ParallelSortedSetIterable;
import org.eclipse.collections.impl.lazy.parallel.list.SynchronizedParallelListIterable;
import org.eclipse.collections.impl.lazy.parallel.set.SynchronizedParallelUnsortedSetIterable;
import org.eclipse.collections.impl.lazy.parallel.set.sorted.SynchronizedParallelSortedSetIterable;

public abstract class AbstractSynchronizedParallelIterable> implements ParallelIterable
{
    protected final PI delegate;
    protected final Object lock;

    protected AbstractSynchronizedParallelIterable(PI delegate, Object lock)
    {
        this.delegate = delegate;
        this.lock = lock;
    }

    protected  ParallelListIterable wrap(ParallelListIterable wrapped)
    {
        return new SynchronizedParallelListIterable(wrapped, this.lock);
    }

    protected  ParallelUnsortedSetIterable wrap(ParallelUnsortedSetIterable wrapped)
    {
        return new SynchronizedParallelUnsortedSetIterable(wrapped, this.lock);
    }

    protected  ParallelSortedSetIterable wrap(ParallelSortedSetIterable wrapped)
    {
        return new SynchronizedParallelSortedSetIterable(wrapped, this.lock);
    }

    protected  ParallelIterable wrap(ParallelIterable wrapped)
    {
        return new SynchronizedParallelIterable(wrapped, this.lock);
    }

    public void forEach(Procedure procedure)
    {
        synchronized (this.lock)
        {
            this.delegate.forEach(procedure);
        }
    }

    public 

void forEachWith(Procedure2 procedure, P parameter) { synchronized (this.lock) { this.delegate.forEachWith(procedure, parameter); } } public T detect(Predicate predicate) { synchronized (this.lock) { return this.delegate.detect(predicate); } } public

T detectWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.delegate.detectWith(predicate, parameter); } } public T detectIfNone(Predicate predicate, Function0 function) { synchronized (this.lock) { return this.delegate.detectIfNone(predicate, function); } } public

T detectWithIfNone(Predicate2 predicate, P parameter, Function0 function) { synchronized (this.lock) { return this.delegate.detectWithIfNone(predicate, parameter, function); } } public int count(Predicate predicate) { synchronized (this.lock) { return this.delegate.count(predicate); } } public

int countWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.delegate.countWith(predicate, parameter); } } public boolean anySatisfy(Predicate predicate) { synchronized (this.lock) { return this.delegate.anySatisfy(predicate); } } public

boolean anySatisfyWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.delegate.anySatisfyWith(predicate, parameter); } } public boolean allSatisfy(Predicate predicate) { synchronized (this.lock) { return this.delegate.allSatisfy(predicate); } } public

boolean allSatisfyWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.delegate.allSatisfyWith(predicate, parameter); } } public boolean noneSatisfy(Predicate predicate) { synchronized (this.lock) { return this.delegate.noneSatisfy(predicate); } } public

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.delegate.noneSatisfyWith(predicate, parameter); } } public MutableList toList() { synchronized (this.lock) { return this.delegate.toList(); } } public MutableList toSortedList() { synchronized (this.lock) { return this.delegate.toSortedList(); } } public MutableList toSortedList(Comparator comparator) { synchronized (this.lock) { return this.delegate.toSortedList(comparator); } } public > MutableList toSortedListBy(Function function) { synchronized (this.lock) { return this.delegate.toSortedListBy(function); } } public MutableSet toSet() { synchronized (this.lock) { return this.delegate.toSet(); } } public MutableSortedSet toSortedSet() { synchronized (this.lock) { return this.delegate.toSortedSet(); } } public MutableSortedSet toSortedSet(Comparator comparator) { synchronized (this.lock) { return this.delegate.toSortedSet(comparator); } } public > MutableSortedSet toSortedSetBy(Function function) { synchronized (this.lock) { return this.delegate.toSortedSetBy(function); } } public MutableBag toBag() { synchronized (this.lock) { return this.delegate.toBag(); } } public MutableSortedBag toSortedBag() { synchronized (this.lock) { return this.delegate.toSortedBag(); } } public MutableSortedBag toSortedBag(Comparator comparator) { synchronized (this.lock) { return this.delegate.toSortedBag(comparator); } } public > MutableSortedBag toSortedBagBy(Function function) { synchronized (this.lock) { return this.delegate.toSortedBagBy(function); } } public MutableMap toMap(Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.delegate.toMap(keyFunction, valueFunction); } } public MutableSortedMap toSortedMap(Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.delegate.toSortedMap(keyFunction, valueFunction); } } public MutableSortedMap toSortedMap(Comparator comparator, Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.delegate.toSortedMap(comparator, keyFunction, valueFunction); } } public Object[] toArray() { synchronized (this.lock) { return this.delegate.toArray(); } } public T1[] toArray(T1[] target) { synchronized (this.lock) { return this.delegate.toArray(target); } } public T min(Comparator comparator) { synchronized (this.lock) { return this.delegate.min(comparator); } } public T max(Comparator comparator) { synchronized (this.lock) { return this.delegate.max(comparator); } } public T min() { synchronized (this.lock) { return this.delegate.min(); } } public T max() { synchronized (this.lock) { return this.delegate.max(); } } public > T minBy(Function function) { synchronized (this.lock) { return this.delegate.minBy(function); } } public > T maxBy(Function function) { synchronized (this.lock) { return this.delegate.maxBy(function); } } public long sumOfInt(IntFunction function) { synchronized (this.lock) { return this.delegate.sumOfInt(function); } } public double sumOfFloat(FloatFunction function) { synchronized (this.lock) { return this.delegate.sumOfFloat(function); } } public long sumOfLong(LongFunction function) { synchronized (this.lock) { return this.delegate.sumOfLong(function); } } public double sumOfDouble(DoubleFunction function) { synchronized (this.lock) { return this.delegate.sumOfDouble(function); } } public String makeString() { synchronized (this.lock) { return this.delegate.makeString(); } } public String makeString(String separator) { synchronized (this.lock) { return this.delegate.makeString(separator); } } public String makeString(String start, String separator, String end) { synchronized (this.lock) { return this.delegate.makeString(start, separator, end); } } public void appendString(Appendable appendable) { synchronized (this.lock) { this.delegate.appendString(appendable); } } public void appendString(Appendable appendable, String separator) { synchronized (this.lock) { this.delegate.appendString(appendable, separator); } } public void appendString(Appendable appendable, String start, String separator, String end) { synchronized (this.lock) { this.delegate.appendString(appendable, start, separator, end); } } public MapIterable groupByUniqueKey(Function function) { synchronized (this.lock) { return this.delegate.groupByUniqueKey(function); } } public MapIterable aggregateInPlaceBy(Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator) { synchronized (this.lock) { return this.delegate.aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } } public MapIterable aggregateBy(Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator) { synchronized (this.lock) { return this.delegate.aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } } @Override public String toString() { synchronized (this.lock) { return this.delegate.toString(); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy