mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 11:46:06 +00:00
add IntObjConsumer and forEach implementation in Column
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import com.dfsek.terra.api.util.function.IntObjConsumer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -20,9 +22,15 @@ public interface Column<T> {
|
||||
}
|
||||
}
|
||||
|
||||
default void forEach(IntObjConsumer<T> consumer) {
|
||||
for(int y = getMinY(); y < getMaxY(); y++) {
|
||||
consumer.accept(y, get(y));
|
||||
}
|
||||
}
|
||||
|
||||
default List<? extends T> asList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
forEach(list::add);
|
||||
forEach((Consumer<T>) list::add);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.dfsek.terra.api.util.function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IntObjConsumer<T> {
|
||||
void accept(int i, T obj);
|
||||
}
|
||||
Reference in New Issue
Block a user