/** * Append all elements in a list to buffer. */ public ListBuffer<A> appendList(ImmutableList<A> xs) { while (xs.nonEmpty()) { append(xs.head); xs = xs.tail; } return this; }
/** * Append all elements in a list to buffer. */ public ListBuffer<A> appendList(ImmutableList<A> xs) { while (xs.nonEmpty()) { append(xs.head); xs = xs.tail; } return this; }
/** * Append all elements in a list to buffer. */ public ListBuffer<A> appendList(ImmutableList<A> xs) { while (xs.nonEmpty()) { append(xs.head); xs = xs.tail; } return this; }
/** * Form a string listing all elements with given separator character. */ public String toString(final String sep) { if (isEmpty()) { return StringUtilities.EMPTY; } else { final StringBuilder buffer = new StringBuilder(); buffer.append(head); for (ImmutableList<A> l = tail; l.nonEmpty(); l = l.tail) { buffer.append(sep); buffer.append(l.head); } return buffer.toString(); } }
/** * Form a string listing all elements with given separator character. */ public String toString(final String sep) { if (isEmpty()) { return StringUtilities.EMPTY; } else { final StringBuilder buffer = new StringBuilder(); buffer.append(head); for (ImmutableList<A> l = tail; l.nonEmpty(); l = l.tail) { buffer.append(sep); buffer.append(l.head); } return buffer.toString(); } }
/** * Form a string listing all elements with given separator character. */ public String toString(final String sep) { if (isEmpty()) { return StringUtilities.EMPTY; } else { final StringBuilder buffer = new StringBuilder(); buffer.append(head); for (ImmutableList<A> l = tail; l.nonEmpty(); l = l.tail) { buffer.append(sep); buffer.append(l.head); } return buffer.toString(); } }
/** * Copy successive elements of this list into given vector until * list is exhausted or end of vector is reached. */ @NotNull @Override @SuppressWarnings("unchecked") public <T> T[] toArray(@NotNull final T[] vec) { int i = 0; ImmutableList<A> l = this; while (l.nonEmpty() && i < vec.length) { vec[i] = (T)l.head; l = l.tail; i++; } if (l.isEmpty()) { if (i < vec.length) { vec[i] = null; } return vec; } return toArray((T[])Array.newInstance(vec.getClass().getComponentType(), size())); }
/** * Copy successive elements of this list into given vector until * list is exhausted or end of vector is reached. */ @NotNull @Override @SuppressWarnings("unchecked") public <T> T[] toArray(@NotNull final T[] vec) { int i = 0; ImmutableList<A> l = this; while (l.nonEmpty() && i < vec.length) { vec[i] = (T)l.head; l = l.tail; i++; } if (l.isEmpty()) { if (i < vec.length) { vec[i] = null; } return vec; } return toArray((T[])Array.newInstance(vec.getClass().getComponentType(), size())); }
/** * Reverse list. * If the list is empty or a singleton, then the same list is returned. * Otherwise a new list is formed. */ public ImmutableList<A> reverse() { // if it is empty or a singleton, return itself if (isEmpty() || tail.isEmpty()) { return this; } ImmutableList<A> rev = empty(); for (ImmutableList<A> l = this; l.nonEmpty(); l = l.tail) { rev = new ImmutableList<>(l.head, rev); } return rev; }
/** * Reverse list. * If the list is empty or a singleton, then the same list is returned. * Otherwise a new list is formed. */ public ImmutableList<A> reverse() { // if it is empty or a singleton, return itself if (isEmpty() || tail.isEmpty()) { return this; } ImmutableList<A> rev = empty(); for (ImmutableList<A> l = this; l.nonEmpty(); l = l.tail) { rev = new ImmutableList<>(l.head, rev); } return rev; }
/** * Reverse list. * If the list is empty or a singleton, then the same list is returned. * Otherwise a new list is formed. */ public ImmutableList<A> reverse() { // if it is empty or a singleton, return itself if (isEmpty() || tail.isEmpty()) { return this; } ImmutableList<A> rev = empty(); for (ImmutableList<A> l = this; l.nonEmpty(); l = l.tail) { rev = new ImmutableList<>(l.head, rev); } return rev; }
public static int rank(final Type t) { if (t == null) { return 0; } if (t.isPrimitive() || t.isWildcardType() || t.isArray() || t == Type.Bottom || t == Type.NullType) { throw new AssertionError(); } if (t == Types.Object) { return 0; } int r = rank(superType(t)); for (ImmutableList<Type<?>> l = interfaces(t); l.nonEmpty(); l = l.tail) { final int headRank = rank(l.head); if (headRank > r) { r = headRank; } } return r + 1; }
public static int rank(final Type t) { if (t == null) { return 0; } if (t.isPrimitive() || t.isWildcardType() || t.isArray() || t == Type.Bottom || t == Type.NullType) { throw new AssertionError(); } if (t == Types.Object) { return 0; } int r = rank(superType(t)); for (ImmutableList<Type<?>> l = interfaces(t); l.nonEmpty(); l = l.tail) { final int headRank = rank(l.head); if (headRank > r) { r = headRank; } } return r + 1; }
public static int rank(final Type t) { if (t == null) { return 0; } if (t.isPrimitive() || t.isWildcardType() || t.isArray() || t == Type.Bottom || t == Type.NullType) { throw new AssertionError(); } if (t == Types.Object) { return 0; } int r = rank(superType(t)); for (ImmutableList<Type<?>> l = interfaces(t); l.nonEmpty(); l = l.tail) { final int headRank = rank(l.head); if (headRank > r) { r = headRank; } } return r + 1; }