This commit is contained in:
Redkale
2017-08-14 16:22:46 +08:00
parent 93a7bd63cf
commit 24505564c8

View File

@@ -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);