private void advance() { nextAlignment = null; Row nextRow = null; while (nextAlignment == null && !rows.isEmpty()) { while ((nextRow = rows.poll()) != null) { if (nextRow.hasNext()) { nextAlignment = nextRow.nextAlignment(); break; } } } if (nextRow != null && nextAlignment != null) { rows.add(nextRow); } }