Concatenate an list of arrays of typed-objects
@param empty An empty array of the right type used for cloning
@param arrayList A list of arrays to concatenate.
@return The concatenated mega-array.
963198
public static <T> T[] concatAll(final T[] empty, Iterable<T[]> arrayList) {
        assert(empty.length == 0);
        if (arrayList.iterator().hasNext() == false) {
            return empty;
        }

        int len = 0;
        for (T[] subArray : arrayList) {
            len += subArray.length;
        }
        int pos = 0;
        T[] result = Arrays.copyOf(empty, len);
        for (T[] subArray : arrayList) {
            System.arraycopy(subArray, 0, result, pos, subArray.length);
            pos += subArray.length;
        }
        return result;
    }
395478
public static <T> List<T> toList(T[] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
1087122
private String[] mergeAndConvert(List<String> list, String[] array) {
        Set<String> set = new HashSet<String>(Arrays.asList(array));
        set.addAll(list);
        return set.toArray(new String[set.size()]);
    }
262760
@SuppressWarnings("unchecked")
    public static <T> List<T> concat(final Iterable<T> first, final Iterable<T> ... other) {
        List<T> list = newArrayList(first);
        for (Iterable<T> iter : other) {
            list.addAll(newArrayList(iter));
        }
        return list;
    }
1213020
public static <T> List<T> arrayToList(T [] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
869183
public static Expression asList(Iterable<? extends Expression> items) {
    final ImmutableList<Expression> copy = ImmutableList.copyOf(items);
    if (copy.isEmpty()) {
      return MethodRef.IMMUTABLE_LIST_OF.get(0).invoke();
    }
    // Note, we cannot necessarily use ImmutableList for anything besides the empty list because
    // we may need to put a null in it.
    final Expression construct = ConstructorRef.ARRAY_LIST_SIZE.construct(constant(copy.size()));
    return new Expression(ARRAY_LIST_TYPE, Feature.NON_NULLABLE) {
      @Override
      protected void doGen(CodeBuilder mv) {
        construct.gen(mv);
        for (Expression child : copy) {
          mv.dup();
          child.gen(mv);
          MethodRef.ARRAY_LIST_ADD.invokeUnchecked(mv);
          mv.pop(); // pop the bool result of arraylist.add
        }
      }
    };
  }
1112053
public static <T> List<T> emptyToNull(final List<T> list) {
        if (isEmpty(list)) {
            return null;
        } else {
            return list;
        }
    }
1215029
public static <T> List<T> arrayToList(T[] array) {
        List<T> list = null;
        if (array != null) {
            list = new ArrayList<>();
            for (T e : array) {
                list.add(e);
            }
        }
        return list;
    }
424551
@Override
	public <T> T[] toArray(T[] a) {
		combine();
		if(combined==null) {
			Set<E> emptySet = java.util.Collections.emptySet();
			return emptySet.toArray(a);
		}
		return combined.toArray(a);
	}
888460
public static int[] concatenate (int[] v1, int[] v2)
    {
        int[] values = new int[v1.length + v2.length];
        System.arraycopy(v1, 0, values, 0, v1.length);
        System.arraycopy(v2, 0, values, v1.length, v2.length);
        return values;
    }
977615
@Nonnull
    public final ArrayList<A> toArrayList() {
        ArrayList<A> list = new ArrayList<>(this.length);
        ImmutableList<A> l = this;
        for (int i = 0; i < length; i++) {
            list.add(((NonEmptyImmutableList<A>) l).head);
            l = ((NonEmptyImmutableList<A>) l).tail;
        }
        return list;
    }
1092760
@Override
    public C.List<T> prepend(C.List<T> list) {
        return prependList(list);
    }
525946
private String serializeArrayList(ArrayList<String> strings) {
        String retString = "";
        for (String value : strings) {
            retString = retString + value + ",";
        }
        retString = retString.substring(0, retString.length() - 1);
        return retString;
    }
417233
public static <T> JSONArray listToJSONArray(final List<T> list) {
        final JSONArray ret = new JSONArray();

        if (null == list) {
            return ret;
        }

        for (final T object : list) {
            ret.put(object);
        }

        return ret;
    }
658360
public static Array listToArrayRemoveEmpty(String list, char delimiter) {
	int len = list.length();
	ArrayImpl array = new ArrayImpl();
	if (len == 0) return array;
	int last = 0;

	for (int i = 0; i < len; i++) {
	    if (list.charAt(i) == delimiter) {
		if (last < i) array.appendEL(list.substring(last, i));
		last = i + 1;
	    }
	}
	if (last < len) array.appendEL(list.substring(last));

	return array;
    }
999724
public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) {
        return () -> Iterators.concat(iterators(iterables));
    }
529254
public static <T> T[] concat(T[] a, T... b) {
        int aLen = a.length;
        int bLen = b.length;

        if (bLen == 0) {
            return a;
        }
        if (aLen == 0) {
            return b;
        }

        @SuppressWarnings("unchecked")
        T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
        System.arraycopy(a, 0, c, 0, aLen);
        System.arraycopy(b, 0, c, aLen, bLen);

        return c;
    }