net.minestom.server.utils.collection.ObjectArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.utils.collection;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
/**
* Represents an array which will be resized to the highest required index.
*
* @param the type of the array
*/
@ApiStatus.Internal
public sealed interface ObjectArray
permits ObjectArrayImpl.SingleThread, ObjectArrayImpl.Concurrent {
static @NotNull ObjectArray singleThread(int initialSize) {
return new ObjectArrayImpl.SingleThread<>(initialSize);
}
static @NotNull ObjectArray singleThread() {
return singleThread(0);
}
static @NotNull ObjectArray concurrent(int initialSize) {
return new ObjectArrayImpl.Concurrent<>(initialSize);
}
static @NotNull ObjectArray concurrent() {
return concurrent(0);
}
@UnknownNullability T get(int index);
void set(int index, @Nullable T object);
default void remove(int index) {
set(index, null);
}
void trim();
@UnknownNullability T @NotNull [] arrayCopy(@NotNull Class type);
}