chore: simplify code
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ConcurrentTable<X, Y, Z> implements AbstractConcurrentTable<X, Y, Z> {
|
||||
@@ -150,7 +151,7 @@ public class ConcurrentTable<X, Y, Z> implements AbstractConcurrentTable<X, Y, Z
|
||||
}
|
||||
|
||||
private <T> List<T> filterAndCollect(Predicate<TableEntry<X, Y, Z>> filter,
|
||||
java.util.function.Function<TableEntry<X, Y, Z>, T> mapper) {
|
||||
Function<TableEntry<X, Y, Z>, T> mapper) {
|
||||
List<T> result = new ArrayList<>();
|
||||
for (TableEntry<X, Y, Z> entry : data) {
|
||||
if (filter.test(entry)) {
|
||||
@@ -161,8 +162,8 @@ public class ConcurrentTable<X, Y, Z> implements AbstractConcurrentTable<X, Y, Z
|
||||
}
|
||||
|
||||
private <K, V> Map<K, V> filterAndMap(Predicate<TableEntry<X, Y, Z>> filter,
|
||||
java.util.function.Function<TableEntry<X, Y, Z>, K> keyMapper,
|
||||
java.util.function.Function<TableEntry<X, Y, Z>, V> valueMapper) {
|
||||
Function<TableEntry<X, Y, Z>, K> keyMapper,
|
||||
Function<TableEntry<X, Y, Z>, V> valueMapper) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
for (TableEntry<X, Y, Z> entry : data) {
|
||||
if (filter.test(entry)) {
|
||||
@@ -172,7 +173,7 @@ public class ConcurrentTable<X, Y, Z> implements AbstractConcurrentTable<X, Y, Z
|
||||
return map;
|
||||
}
|
||||
|
||||
private <T> List<T> collectAll(java.util.function.Function<TableEntry<X, Y, Z>, T> mapper) {
|
||||
private <T> List<T> collectAll(Function<TableEntry<X, Y, Z>, T> mapper) {
|
||||
List<T> result = new ArrayList<>();
|
||||
for (TableEntry<X, Y, Z> entry : data) {
|
||||
result.add(mapper.apply(entry));
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ public class OptimizedConcurrentTable<X, Y, Z> extends ConcurrentTable<X, Y, Z>
|
||||
}
|
||||
|
||||
|
||||
private <K, V, R, S> Map<R, S> buildMapFromIndex(ConcurrentHashMap<K, Set<V>> indexMap, java.util.function.Function<K, R> keyMapper, java.util.function.Function<V, S> valueMapper) {
|
||||
private <K, V, R, S> Map<R, S> buildMapFromIndex(ConcurrentHashMap<K, Set<V>> indexMap, Function<K, R> keyMapper, Function<V, S> valueMapper) {
|
||||
Map<R, S> result = new HashMap<>();
|
||||
if (indexMap != null) {
|
||||
for (Map.Entry<K, Set<V>> entry : indexMap.entrySet()) {
|
||||
|
||||
Reference in New Issue
Block a user