-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScalarIP.java
More file actions
70 lines (65 loc) · 2.39 KB
/
ScalarIP.java
File metadata and controls
70 lines (65 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package info.kgeorgiy.java.advanced.concurrent;
import java.util.Comparator;
import java.util.List;
import java.util.function.Predicate;
/**
* Scalar iterative parallelism support.
*
* @author Georgiy Korneev (kgeorgiy@kgeorgiy.info)
*/
public interface ScalarIP {
/**
* Returns maximum value.
*
* @param threads number or concurrent threads.
* @param values values to get maximum of.
* @param comparator value comparator.
* @param <T> value type.
*
* @return maximum of given values
*
* @throws InterruptedException if executing thread was interrupted.
* @throws java.util.NoSuchElementException if not values are given.
*/
<T> T maximum(int threads, List<? extends T> values, Comparator<? super T> comparator) throws InterruptedException;
/**
* Returns minimum value.
*
* @param threads number or concurrent threads.
* @param values values to get minimum of.
* @param comparator value comparator.
* @param <T> value type.
*
* @return minimum of given values
*
* @throws InterruptedException if executing thread was interrupted.
* @throws java.util.NoSuchElementException if not values are given.
*/
<T> T minimum(int threads, List<? extends T> values, Comparator<? super T> comparator) throws InterruptedException;
/**
* Returns whether all values satisfies predicate.
*
* @param threads number or concurrent threads.
* @param values values to test.
* @param predicate test predicate.
* @param <T> value type.
*
* @return whether all values satisfies predicate or {@code true}, if no values are given.
*
* @throws InterruptedException if executing thread was interrupted.
*/
<T> boolean all(int threads, List<? extends T> values, Predicate<? super T> predicate) throws InterruptedException;
/**
* Returns whether any of values satisfies predicate.
*
* @param threads number or concurrent threads.
* @param values values to test.
* @param predicate test predicate.
* @param <T> value type.
*
* @return whether any value satisfies predicate or {@code false}, if no values are given.
*
* @throws InterruptedException if executing thread was interrupted.
*/
<T> boolean any(int threads, List<? extends T> values, Predicate<? super T> predicate) throws InterruptedException;
}