| 1 |
package inference.guava; |
| 2 |
|
| 3 |
import java.util.Comparator; |
| 4 |
import java.util.List; |
| 5 |
import java.util.stream.Collector; |
| 6 |
|
| 7 |
@SuppressWarnings("") // Just check for crashes. |
| 8 |
public class Bug10 { |
| 9 |
public static <T> Collector<T, ?, List<T>> least(int k, Comparator<? super T> comparator) { |
| 10 |
return Collector.of( |
| 11 |
() -> TopKSelector.<T>least(k, comparator), |
| 12 |
TopKSelector::offer, |
| 13 |
TopKSelector::combine, |
| 14 |
TopKSelector::topK, |
| 15 |
Collector.Characteristics.UNORDERED); |
| 16 |
} |
| 17 |
|
| 18 |
static final class TopKSelector<T> { |
| 19 |
TopKSelector<T> combine(TopKSelector<T> other) { |
| 20 |
throw new RuntimeException(); |
| 21 |
} |
| 22 |
|
| 23 |
public static <T extends Comparable<? super T>> TopKSelector<T> least(int k) { |
| 24 |
throw new RuntimeException(); |
| 25 |
} |
| 26 |
|
| 27 |
public static <T extends Comparable<? super T>> TopKSelector<T> greatest(int k) { |
| 28 |
throw new RuntimeException(); |
| 29 |
} |
| 30 |
|
| 31 |
public static <T> TopKSelector<T> least(int k, Comparator<? super T> comparator) { |
| 32 |
return new TopKSelector<T>(comparator, k); |
| 33 |
} |
| 34 |
|
| 35 |
public static <T> TopKSelector<T> greatest(int k, Comparator<? super T> comparator) { |
| 36 |
throw new RuntimeException(); |
| 37 |
} |
| 38 |
|
| 39 |
private TopKSelector(Comparator<? super T> comparator, int k) {} |
| 40 |
|
| 41 |
public void offer(T elem) { |
| 42 |
throw new RuntimeException(); |
| 43 |
} |
| 44 |
|
| 45 |
public List<T> topK() { |
| 46 |
throw new RuntimeException(); |
| 47 |
} |
| 48 |
} |
| 49 |
} |