public boolean hasNext() { if (next == null) { if (index != Integer.MAX_VALUE) { int pos = value.indexOf('\n', index); int nextIndex; if (pos == -1) { pos = Math.min(index + width, value.length()); nextIndex = pos; } else { if (pos <= index + width) { nextIndex = pos + 1; } else { nextIndex = pos = index + width; } } next = Pair.of(index, pos); if (pos < value.length()) { index = nextIndex; } else { // Stop value index = Integer.MAX_VALUE; } } } return next != null; }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
public boolean hasNext() { if (next == null) { if (index != Integer.MAX_VALUE) { int pos = value.indexOf('\n', index); int nextIndex; if (pos == -1) { pos = Math.min(index + width, value.length()); nextIndex = pos; } else { if (pos <= index + width) { nextIndex = pos + 1; } else { nextIndex = pos = index + width; } } next = Pair.of(index, pos); if (pos < value.length()) { index = nextIndex; } else { // Stop value index = Integer.MAX_VALUE; } } } return next != null; }
public boolean hasNext() { if (next == null) { if (index != Integer.MAX_VALUE) { int pos = value.indexOf('\n', index); int nextIndex; if (pos == -1) { pos = Math.min(index + width, value.length()); nextIndex = pos; } else { if (pos <= index + width) { nextIndex = pos + 1; } else { nextIndex = pos = index + width; } } next = Pair.of(index, pos); if (pos < value.length()) { index = nextIndex; } else { // Stop value index = Integer.MAX_VALUE; } } } return next != null; }
public boolean hasNext() { if (next == null) { if (index != Integer.MAX_VALUE) { int pos = value.indexOf('\n', index); int nextIndex; if (pos == -1) { pos = Math.min(index + width, value.length()); nextIndex = pos; } else { if (pos <= index + width) { nextIndex = pos + 1; } else { nextIndex = pos = index + width; } } next = Pair.of(index, pos); if (pos < value.length()) { index = nextIndex; } else { // Stop value index = Integer.MAX_VALUE; } } } return next != null; }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }