This commit is contained in:
Daniel Mills
2021-08-05 21:24:52 -04:00
parent e636a6ad58
commit f091256edb
11 changed files with 191 additions and 59 deletions

View File

@@ -20,10 +20,12 @@ package com.volmit.iris.util.hunk.storage;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.function.Consumer4IO;
import com.volmit.iris.util.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.IOException;
import java.util.Map;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@@ -69,6 +71,20 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
return this;
}
@Override
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
idx = g.getKey();
z = idx / (getWidth() * getHeight());
idx -= (z * getWidth() * getHeight());
c.accept(idx % getWidth(), idx / getWidth(), z, g.getValue());
}
return this;
}
@Override
public void empty(T b) {
data.clear();