package at.yawk.numaec;
import org.eclipse.collections.api.ByteIterable;
import org.eclipse.collections.api.factory.list.primitive.MutableByteListFactory;
public class MutableByteBufferListFactory implements MutableByteListFactory {
private final LargeByteBufferAllocator allocator;
private MutableByteBufferListFactory(LargeByteBufferAllocator allocator) {
this.allocator = allocator;
}
public static MutableByteBufferListFactory withAllocator(LargeByteBufferAllocator allocator) {
return new MutableByteBufferListFactory(allocator);
}
@Override
public MutableByteBufferList empty() {
return new ByteBufferListImpl.Mutable(allocator);
}
public MutableByteBufferList emptyWithInitialCapacity(int initialCapacity) {
return new ByteBufferListImpl.Mutable(allocator, initialCapacity);
}
@Override
public MutableByteBufferList of() {
return empty();
}
@Override
public MutableByteBufferList with() {
return empty();
}
@Override
public MutableByteBufferList of(byte... items) {
MutableByteBufferList list = emptyWithInitialCapacity(items.length);
list.addAll(items);
return list;
}
@Override
public MutableByteBufferList with(byte... items) {
return of(items);
}
@Override
public MutableByteBufferList ofAll(ByteIterable items) {
MutableByteBufferList list = emptyWithInitialCapacity(items.size());
list.addAll(items);
return list;
}
@Override
public MutableByteBufferList withAll(ByteIterable items) {
return ofAll(items);
}
@Override
public MutableByteBufferList ofAll(Iterable<Byte> iterable) {
MutableByteBufferList list = of();
for (Byte element : iterable) {
list.add(element);
}
return list;
}
@Override
public MutableByteBufferList withAll(Iterable<Byte> iterable) {
return ofAll(iterable);
}
}