This commit is contained in:
Daniel Mills
2021-08-07 08:16:24 -04:00
parent 6683eee49a
commit 6a68da0559
14 changed files with 138 additions and 237 deletions

View File

@@ -1069,41 +1069,38 @@ public interface Hunk<T> {
/**
* Create a hunk that is optimized for specific uses
* @param w width
* @param h height
* @param d depth
* @param type the class type
* @param packed if the hunk is generally more than 50% full (non-null nodes)
*
* @param w width
* @param h height
* @param d depth
* @param type the class type
* @param packed if the hunk is generally more than 50% full (non-null nodes)
* @param concurrent if this hunk must be thread safe
* @param <T> the type
* @param <T> the type
* @return the hunk
*/
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent)
{
if(type.equals(Double.class))
{
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent) {
if (type.equals(Double.class)) {
return concurrent ?
packed ? (Hunk<T>) newAtomicDoubleHunk(w,h,d) : newMappedHunk(w,h,d)
: packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d);
packed ? (Hunk<T>) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d)
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
}
if(type.equals(Integer.class))
{
if (type.equals(Integer.class)) {
return concurrent ?
packed ? (Hunk<T>) newAtomicIntegerHunk(w,h,d) : newMappedHunk(w,h,d)
: packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d);
packed ? (Hunk<T>) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d)
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
}
if(type.equals(Long.class))
{
if (type.equals(Long.class)) {
return concurrent ?
packed ? (Hunk<T>) newAtomicLongHunk(w,h,d) : newMappedHunk(w,h,d)
: packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d);
packed ? (Hunk<T>) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d)
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
}
return concurrent ?
packed ? newAtomicHunk(w,h,d) : newMappedHunk(w,h,d)
: packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d);
packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d)
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
}
default void setIfExists(int x, int y, int z, T t) {
@@ -1449,8 +1446,7 @@ public interface Hunk<T> {
c[1] = y;
}
default boolean isEmpty()
{
default boolean isEmpty() {
return false;
}
}

View File

@@ -20,7 +20,6 @@ package com.volmit.iris.util.hunk.storage;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.HunkFactory;
import lombok.Data;
import lombok.EqualsAndHashCode;

View File

@@ -47,8 +47,7 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
return true;
}
public boolean isEmpty()
{
public boolean isEmpty() {
return data.isEmpty();
}