This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
package org.redkale.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
/**
|
||||
@@ -108,6 +108,15 @@ public class Sheet<T> implements java.io.Serializable, Iterable<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public <R> Sheet<R> map(Function<T, R> mapper) {
|
||||
if (this.isEmpty()) return (Sheet) this;
|
||||
final List<R> list = new ArrayList<>();
|
||||
for (T item : this.rows) {
|
||||
list.add(mapper.apply(item));
|
||||
}
|
||||
return new Sheet<>(getTotal(), list);
|
||||
}
|
||||
|
||||
public void forEachParallel(final Consumer<? super T> consumer) {
|
||||
if (consumer != null && this.rows != null && !this.rows.isEmpty()) {
|
||||
this.rows.parallelStream().forEach(consumer);
|
||||
|
||||
Reference in New Issue
Block a user