Converts an {@link Integer} list to an int array. Null values are
converted to zero.
@param list the {@link Integer} list
@return the int array
434471
private static int[] toIntArray(List<Integer> list) {
		int[] array = new int[list.size()];
		int i = 0;
		for (Integer intObj : list) {
			array[i++] = toInt(intObj);
		}
		return array;
	}
1006869
private static <T> T firstOf(final List<T> list) {
        return list.isEmpty()? null: list.get(0);
    }
23329
static public int sizeOf(WsByteBuffer[] list) {
        if (null == list) {
            return 0;
        }
        int size = 0;
        for (int i = 0; i < list.length; i++) {
            if (null != list[i]) {
                size += list[i].remaining();
            }
        }
        return size;
    }
1347114
public static Object[] toArray(List<?> list) {
	Iterator<?> it = list.iterator();
	Class clazz = null;
	while (it.hasNext()) {
	    Object v = it.next();
	    if (v == null) continue;
	    if (clazz == null) clazz = v.getClass();
	    else if (clazz != v.getClass()) return list.toArray();
	}
	if (clazz == Object.class || clazz == null) return list.toArray();

	Object arr = java.lang.reflect.Array.newInstance(clazz, list.size());
	return list.toArray((Object[]) arr);
    }
3733
public static <T> T firstEntry(final List<T> list) {
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }
649727
public static List<Integer> asList(int[] array) {
    List<Integer> l = new ArrayList<Integer>();
    for (int i : array) {
      l.add(i);
    }
    return l;
  }
115744
@SuppressWarnings("unchecked")
    @NonNull
    public static <T> List<T> unmodifiableNonNullList(@Nullable List<T> list) {
        return list == null || list.isEmpty()
                ? (List<T>) emptyList()
                : unmodifiableList(list);
    }
729841
private static double[] numberListToDoubleArray(List<Number> listOfNumbers) {
		double[] arrayOfDoubles	= new double[listOfNumbers.size()];
		for(int i=0; i<arrayOfDoubles.length; i++) {
			arrayOfDoubles[i] = listOfNumbers.get(i).doubleValue();
		}
		return arrayOfDoubles;
	}
245905
protected <T> List<T> toArrayList(List<T> list) {
        if (list == null) {
            return null;
        }
        if (!list.getClass().equals(ArrayList.class)) {
            list = new ArrayList<>(list);
        }
        return list;
    }
1209473
int[] toIntArray() {
        int[] result = new int[intLen];
        for(int i=0; i < intLen; i++)
            result[i] = value[offset+i];
        return result;
    }
479232
public static int indexOfNull (Object[] list)
    {
        if (list != null) {
            for (int ii=0, nn = list.length; ii < nn; ii++) {
                if (list[ii] == null) {
                    return ii;
                }
            }
        }
        return -1;
    }
1294952
static List<String> integer(String name, @Nullable Integer value) {
    if (value != null) {
      return Arrays.asList("--" + name, value.toString());
    }
    return Collections.emptyList();
  }
1153145
public static <T> T[] listToArray(List<T> list, T[] array) {
        if (list == null || array == null) {
            return null;
        }

        return list.toArray(array);
    }
1108501
public static <E> int indexOf(final List<E> list, final E value) {
        return list.indexOf(value);
    }
1111270
@NonNull
    @Override
    public List<Object> toList() {
        synchronized (lock) {
            final int count = (int) internalArray.count();
            final List<Object> result = new ArrayList<>(count);
            for (int index = 0; index < count; index++) {
                result.add(Fleece.toObject(getMValue(internalArray, index).asNative(internalArray)));
            }
            return result;
        }
    }
269865
protected <T> List<? extends List<T>> toArrayLists(List<List<T>> lists) {
        for (int i = 0; i < lists.size(); i++) {
            List<T> list = lists.get(i);
            lists.set(i, toArrayList(list));
        }
        return lists;
    }
1127242
public static int[] toInt(double[] array) {
        int[] n = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            n[i] = (int) array[i];
        }
        return n;
    }