/** @return the corresponding input @throws IOException doesn't throw */ @Override public CircularArrayInput<T> getInput() throws IOException { return new CircularArrayInput<>(items); }
/** @return next item */ @Override public T get() throws IOException { if(i >= size) { reset(); } return items[i ++]; }
/** @param item the item to put @throws IOException if the destination collection fails to add the item */ @Override public boolean put(final T item) throws IOException { if(i >= capacity) { i = 0; } return super.put(item); }
/** @param buffer buffer for the items @param maxCount the count limit @return the actual count of the items got in the buffer @throws EOFException doesn't throw */ @Override public int get(final List<T> buffer, final int maxCount) throws EOFException, IOException { int n = 0; while(n < maxCount) { if(i >= size) { reset(); } n += super.get(buffer, Math.min(size - i, maxCount - n)); } return n; }
/** @param buffer buffer for the items @param maxCount the count limit @return the actual count of the items got in the buffer @throws EOFException doesn't throw */ @Override public int get(final List<T> buffer, final int maxCount) throws EOFException, IOException { int n = 0; while(n < maxCount) { if(i >= size) { reset(); } n += super.get(buffer, Math.min(size - i, maxCount - n)); } return n; }
/** @return the corresponding input @throws IOException doesn't throw */ @Override public CircularListInput<T> getInput() throws IOException { return new CircularListInput<>(new ArrayList<>(items)); }
/** @param item the item to put @throws IOException if the destination collection fails to add the item */ @Override public boolean put(final T item) throws IOException { if(i >= items.length) { i = 0; } return super.put(item); }
@Override public final T get() throws IOException { if(i == size) { if(loadMore() <= 0) { throw new EOFException(); } } return items.get(i ++); }
/** @return the corresponding input @throws IOException doesn't throw */ @Override public ListInput<T> getInput() throws IOException { return new ListInput<>(items); }
/** @return the corresponding input @throws IOException doesn't throw */ @Override public ArrayInput<T> getInput() throws IOException { return new ArrayInput<>(items); }
@Override public final void reset() throws IOException { super.reset(); poisonedFlag = false; } }
@Override public final int put(final List<T> items) throws IOException { return put(items, 0, items.size()); }
/** @return next item */ @Override public T get() throws IOException { if(i >= size) { reset(); } return items.get(i ++); }
@Override public void close() throws IOException { super.close(); items.clear(); } }
private int loadMore() throws IOException { final T lastItem = size > 0 ? items.get(size - 1) : null; i = 0; items.clear(); return size = loadMoreItems(lastItem); }
return put(buffer.subList(from, to), 0, n);
return put(buffer.subList(from, to), 0, n);
@Override public final int put(final List<T> items) throws IOException { return put(items, 0, items.size()); }
@Override public final int put(final List<T> items) throws IOException { return put(items, 0, items.size()); }
@Override public final int get(final List<T> buffer, final int maxCount) throws IOException { int n = size - i; if(n == 0) { if(loadMore() <= 0) { throw new EOFException(); } } n = Math.min(size - i, maxCount); for(int j = i; j < i + n; j ++) { buffer.add(items.get(j)); } i += n; return n; }