package at.yawk.numaec;

import org.eclipse.collections.api.factory.map.primitive.MutableFloatShortMapFactory;
import org.eclipse.collections.api.map.primitive.FloatShortMap;

public final class MutableFloatShortLinearHashMapFactory implements MutableFloatShortBufferMapFactory {
    private final LargeByteBufferAllocator allocator;
    private final LinearHashMapConfig config;

    private MutableFloatShortLinearHashMapFactory(LargeByteBufferAllocator allocator, LinearHashMapConfig config) {
        this.allocator = allocator;
        this.config = config;
    }

    public static MutableFloatShortMapFactory withAllocator(LargeByteBufferAllocator allocator) {
        return withAllocatorAndConfig(allocator, LinearHashMapConfig.builder().build());
    }

    public static MutableFloatShortMapFactory withAllocatorAndConfig(
            LargeByteBufferAllocator allocator, LinearHashMapConfig config
    ) {
        return new MutableFloatShortLinearHashMapFactory(allocator, config);
    }

    @Override
    public MutableFloatShortBufferMap empty() {
        return new FloatShortLinearHashMap.Mutable(allocator, config);
    }

    @Override
    public MutableFloatShortBufferMap ofInitialCapacity(int capacity) {
        FloatShortLinearHashMap.Mutable map = new FloatShortLinearHashMap.Mutable(allocator, config);
        map.ensureCapacity(capacity);
        return map;
    }

    @Override
    public MutableFloatShortBufferMap ofAll(FloatShortMap map) {
        MutableFloatShortBufferMap n = ofInitialCapacity(map.size());
        n.putAll(map);
        return n;
    }
}