T () { if (!hasNext()) { throw new NoSuchElementException( "Nothing to offer: " + "unprocessed=" + unprocessedItems + ", processed=" + processedItems + ", current=" + currentItems ); } if (unprocessedItems.isEmpty()) { unprocessedItems = processedItems; processedItems = new ArrayDeque<>(); } T item = unprocessedItems.poll(); processedItems.add(item); return item; }