List of utility methods to do Iterable
T | getByIndex(Iterable get By Index T el = null; Iterator<T> it = iterable.iterator(); for (int i = 0; it.hasNext(); i++) { T cur = it.next(); if (i == index) { el = cur; break; return el; |
DataType | getElement(final Iterable Returns the indexed value into the Iterable . if (iterable instanceof List<?>) { return ((List<DataType>) iterable).get(index); } else { if (index < 0) { throw new IndexOutOfBoundsException("index must be >= 0"); for (DataType v : iterable) { if (index == 0) { ... |
T | getIdenticalElement(Iterable get Identical Element return getIdenticalElement(iterable.iterator());
|
String | getLongestCommonToken(Iterable get Longest Common Token Iterator<String> it = iterable.iterator(); String commonToken = it.next(); while (it.hasNext()) { if (commonToken == "") { return null; String name = it.next(); if (!name.startsWith(commonToken)) { ... |
String | getMessageString(Iterable msgs) get Message String String str = ""; Iterator iter = msgs.iterator(); while (iter.hasNext()) str += iter.next() + ", "; return str; |
T | getUnique(Iterable get Unique final Iterator<? extends T> iter = iterable.iterator(); if (!iter.hasNext()) { throw new IllegalArgumentException("No element in " + iterable); final T result = iter.next(); if (iter.hasNext()) { throw new IllegalArgumentException("More than (expected) one element in " + iterable); return result; |
String | implodeStrings(Iterable implode Strings StringBuffer stringBuffer = new StringBuffer(); for (Iterator<String> i = strings.iterator(); i.hasNext();) { String varClassName = i.next(); stringBuffer.append(varClassName); if (i.hasNext()) { stringBuffer.append(glue); return stringBuffer.toString(); |
int | indexOfSame(Iterable index Of Same int ix = 0; Iterator<? extends T> iterator = iterable.iterator(); while (iterator.hasNext()) { T element = iterator.next(); if (element == obj) return ix; ix++; return -1; |
void | internalSeparate(StringBuilder buff, Iterable> args, String separator, String useWhenNone) internal Separate Iterator<?> i = args.iterator(); if (i.hasNext()) { for (;;) { Object thing = i.next(); buff.append(thing.toString()); if (i.hasNext()) { buff.append(separator); } else ... |
boolean | isEmpty(Iterable> iterable)isEmpty( null ) = true isEmpty( Arrays.asList()) = true isEmpty( Arrays.asList("") ) = false boolean retval = true; if (iterable != null) { Iterator<?> iterator = iterable.iterator(); retval = iterator == null || !iterator.hasNext(); return retval; |