All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.utils.collection.ObjectArray Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy