package at.yawk.numaec;
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.factory.list.primitive.MutableIntListFactory;
import java.util.stream.IntStream;
public class MutableIntBufferListFactory implements MutableIntListFactory {
private final LargeByteBufferAllocator allocator;
private MutableIntBufferListFactory(LargeByteBufferAllocator allocator) {
this.allocator = allocator;
}
public static MutableIntBufferListFactory withAllocator(LargeByteBufferAllocator allocator) {
return new MutableIntBufferListFactory(allocator);
}
@Override
public MutableIntBufferList empty() {
return new IntBufferListImpl.Mutable(allocator);
}
public MutableIntBufferList emptyWithInitialCapacity(int initialCapacity) {
return new IntBufferListImpl.Mutable(allocator, initialCapacity);
}
@Override
public MutableIntBufferList of() {
return empty();
}
@Override
public MutableIntBufferList with() {
return empty();
}
@Override
public MutableIntBufferList of(int... items) {
MutableIntBufferList list = emptyWithInitialCapacity(items.length);
list.addAll(items);
return list;
}
@Override
public MutableIntBufferList with(int... items) {
return of(items);
}
@Override
public MutableIntBufferList ofAll(IntIterable items) {
MutableIntBufferList list = emptyWithInitialCapacity(items.size());
list.addAll(items);
return list;
}
@Override
public MutableIntBufferList withAll(IntIterable items) {
return ofAll(items);
}
@Override
public MutableIntBufferList ofAll(Iterable<Integer> iterable) {
MutableIntBufferList list = of();
for (Integer element : iterable) {
list.add(element);
}
return list;
}
@Override
public MutableIntBufferList withAll(Iterable<Integer> iterable) {
return ofAll(iterable);
}
@Override
public MutableIntBufferList ofAll(IntStream stream) {
MutableIntBufferList list = of();
stream.forEach(list::add);
return list;
}
@Override
public MutableIntBufferList withAll(IntStream stream) {
return ofAll(stream);
}
}