package at.yawk.numaec;

import org.eclipse.collections.api.factory.map.primitive.MutableLongCharMapFactory;
import org.eclipse.collections.api.map.primitive.LongCharMap;

public final class MutableLongCharLinearHashMapFactory implements MutableLongCharBufferMapFactory {
    private final LargeByteBufferAllocator allocator;
    private final LinearHashMapConfig config;

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

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

    public static MutableLongCharMapFactory withAllocatorAndConfig(
            LargeByteBufferAllocator allocator, LinearHashMapConfig config
    ) {
        return new MutableLongCharLinearHashMapFactory(allocator, config);
    }

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

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

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