/** * Prepend given element to front of list, forming and returning * a new list. */ public ImmutableList<A> prepend(final A x) { return new ImmutableList<>(x, this); }
public final void clear() { this.elements = new ImmutableList<>(null, null); this.last = this.elements; count = 0; shared = false; }
/** * Prepend given element to front of list, forming and returning * a new list. */ public ImmutableList<A> prepend(final A x) { return new ImmutableList<>(x, this); }
/** * Prepend given element to front of list, forming and returning * a new list. */ public ImmutableList<A> prepend(final A x) { return new ImmutableList<>(x, this); }
public final void clear() { this.elements = new ImmutableList<>(null, null); this.last = this.elements; count = 0; shared = false; }
/** * Construct a list consisting of given elements. */ @SuppressWarnings({"varargs", "unchecked"}) public static <A> ImmutableList<A> of(final A x1, final A x2, final A x3, final A... rest) { return new ImmutableList<>(x1, new ImmutableList<>(x2, new ImmutableList<>(x3, from(rest)))); }
/** * Construct a list consisting of given elements. */ @SuppressWarnings({"varargs", "unchecked"}) public static <A> ImmutableList<A> of(final A x1, final A x2, final A x3, final A... rest) { return new ImmutableList<>(x1, new ImmutableList<>(x2, new ImmutableList<>(x3, from(rest)))); }
/** * Construct a list consisting of given elements. */ @SafeVarargs public static <A> ImmutableList<A> of(final A x1, final A... rest) { return new ImmutableList<>(x1, from(rest)); }
/** * Construct a list consisting of given element. */ public static <A> ImmutableList<A> of(final A x1) { return new ImmutableList<>(x1, ImmutableList.<A>empty()); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2) { return new ImmutableList<>(x1, of(x2)); }
/** * Construct a list consisting of given elements. */ @SafeVarargs public static <A> ImmutableList<A> of(final A x1, final A... rest) { return new ImmutableList<>(x1, from(rest)); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2) { return new ImmutableList<>(x1, of(x2)); }
/** * Construct a list consisting all elements of given array. * @param array an array; if {@code null} return an empty list */ public static <A> ImmutableList<A> from(final A[] array) { ImmutableList<A> xs = empty(); if (array != null) { for (int i = array.length - 1; i >= 0; i--) { xs = new ImmutableList<>(array[i], xs); } } return xs; }
/** * Construct a list consisting of given element. */ public static <A> ImmutableList<A> of(final A x1) { return new ImmutableList<>(x1, ImmutableList.<A>empty()); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2, final A x3) { return new ImmutableList<>(x1, of(x2, x3)); }
/** * Construct a list consisting of given element. */ public static <A> ImmutableList<A> of(final A x1) { return new ImmutableList<>(x1, ImmutableList.<A>empty()); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2, final A x3) { return new ImmutableList<>(x1, of(x2, x3)); }
/** * Construct a list consisting of given elements. */ @SafeVarargs public static <A> ImmutableList<A> of(final A x1, final A... rest) { return new ImmutableList<>(x1, from(rest)); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2, final A x3) { return new ImmutableList<>(x1, of(x2, x3)); }
/** * Construct a list consisting of given elements. */ public static <A> ImmutableList<A> of(final A x1, final A x2) { return new ImmutableList<>(x1, of(x2)); }