mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-30 05:40:34 +00:00
add IntObjConsumer and forEach implementation in Column
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.dfsek.terra.api.util;
|
package com.dfsek.terra.api.util;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.function.IntObjConsumer;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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() {
|
default List<? extends T> asList() {
|
||||||
List<T> list = new ArrayList<>();
|
List<T> list = new ArrayList<>();
|
||||||
forEach(list::add);
|
forEach((Consumer<T>) list::add);
|
||||||
return list;
|
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