package at.yawk.numaec;

import org.eclipse.collections.api.CharIterable;
import org.eclipse.collections.api.factory.list.primitive.MutableCharListFactory;


public class MutableCharBufferListFactory implements MutableCharListFactory {
    private final LargeByteBufferAllocator allocator;

    private MutableCharBufferListFactory(LargeByteBufferAllocator allocator) {
        this.allocator = allocator;
    }

    public static MutableCharBufferListFactory withAllocator(LargeByteBufferAllocator allocator) {
        return new MutableCharBufferListFactory(allocator);
    }

    @Override
    public MutableCharBufferList empty() {
        return new CharBufferListImpl.Mutable(allocator);
    }

    public MutableCharBufferList emptyWithInitialCapacity(int initialCapacity) {
        return new CharBufferListImpl.Mutable(allocator, initialCapacity);
    }

    @Override
    public MutableCharBufferList of() {
        return empty();
    }

    @Override
    public MutableCharBufferList with() {
        return empty();
    }

    @Override
    public MutableCharBufferList of(char... items) {
        MutableCharBufferList list = emptyWithInitialCapacity(items.length);
        list.addAll(items);
        return list;
    }

    @Override
    public MutableCharBufferList with(char... items) {
        return of(items);
    }

    @Override
    public MutableCharBufferList ofAll(CharIterable items) {
        MutableCharBufferList list = emptyWithInitialCapacity(items.size());
        list.addAll(items);
        return list;
    }

    @Override
    public MutableCharBufferList withAll(CharIterable items) {
        return ofAll(items);
    }

    @Override
    public MutableCharBufferList ofAll(Iterable<Character> iterable) {
        MutableCharBufferList list = of();
        for (Character element : iterable) {
            list.add(element);
        }
        return list;
    }

    @Override
    public MutableCharBufferList withAll(Iterable<Character> iterable) {
        return ofAll(iterable);
    }

}