/*
Documented, #toArray
488731
@SuppressWarnings("unchecked")
    public static <E> E[] toArray(final Iterable<E> iterable) {
        return (E[]) newArrayList(iterable).toArray();
    }
20806
private static List<Object> arrayToList(final Object array) {
    if (array instanceof Object[])
      return Arrays.asList((Object[]) array);

    List<Object> result = new ArrayList<Object>();
    // Arrays of the primitive types can't be cast to array of Object, so this:
    if (array instanceof int[])
      for (int value : (int[]) array) result.add(value);
    else if (array instanceof boolean[])
      for (boolean value : (boolean[]) array) result.add(value);
    else if (array instanceof long[])
      for (long value : (long[]) array) result.add(value);
    else if (array instanceof float[])
      for (float value : (float[]) array) result.add(value);
    else if (array instanceof double[])
      for (double value : (double[]) array) result.add(value);
    else if (array instanceof short[])
      for (short value : (short[]) array) result.add(value);
    else if (array instanceof byte[])
      for (byte value : (byte[]) array) result.add(value);
    else if (array instanceof char[])
      for (char value : (char[]) array) result.add(value);
    return result;
  }
1128330
@SuppressWarnings("unchecked")
    public static <T> T[] toArray(Collection<T> collection, Class<T> clazz) {
        if (collection == null) {
            return null;
        }
        return collection.toArray((T[]) Array.newInstance(clazz, collection.size()));
    }
442028
@SuppressWarnings("unchecked")
	@Override
	public <T> T[] toArray(T[] array) {
		return (T[])(booleanTerms == null ? new BooleanTerm[0] : booleanTerms.toArray(new BooleanTerm[booleanTerms.size()]));
	}
1187314
@SuppressWarnings("unchecked")
	public <T> T[] toArray(T[] a) {
		if (a.length < events.size()) {
			a = (T[]) java.lang.reflect.Array.newInstance(a.getClass()
					.getComponentType(), events.size());
		}
		for (int i = 0; i < events.size(); i++) {
			try {
				a[i] = (T) events.get(i);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}
675479
function toArray(self) {
    if (self instanceof Array) {
        return self;
    } else if (typeof self.toArray === "function") {
        return self.toArray();
    } else if (self.elements) {
        if (self.elements instanceof Array) {
            return self.elements;
        } else if (typeof self.elements === "function") {
            return self.elements();
        }
    } else if (self.items) {
        if (self.items instanceof Array) {
            return self.items;
        } else if (typeof self.items === "function") {
            return self.items();
        }
    }
    throw new Error("(sortedArray) Could not transform instance to array. It should provide either .toArray(), .elements or .items");
}
305549
@Override
    public Object[] toArray() {
        int size = size();
        Object[] retArray;
        if (size < 1) {
            retArray = new Object[] {};
        } else {

            retArray = new Object[size];
            int retArrayIndex = 0;

            synchronized (this) {

                synchronized (lock) {
                    //Add the items in the expedited buffer first
                    //Check if we wrap around the end of the array before iterating
                    if (expeditedPutIndex > expeditedTakeIndex) {
                        for (int i = expeditedTakeIndex; i <= expeditedPutIndex; i++) {
                            retArray[retArrayIndex] = expeditedBuffer[i];
                            retArrayIndex++;
                        }
                    } else {
                        //We wrap around the array. Loop through in two passes(upper and lower)
                        for (int i = expeditedTakeIndex; i < expeditedBuffer.length; i++) {
                            retArray[retArrayIndex] = expeditedBuffer[i];
                            retArrayIndex++;
                        }
                        for (int i = 0; i < expeditedPutIndex; i++) {
                            retArray[retArrayIndex] = expeditedBuffer[i];
                            retArrayIndex++;
                        }
                    }

                    //Next add the items in the main buffer
                    //Check if we wrap around the end of the array before iterating
                    if (putIndex > takeIndex) {
                        for (int i = takeIndex; i <= putIndex; i++) {
                            retArray[retArrayIndex] = buffer[i];
                            retArrayIndex++;
                        }
                    } else {
                        //We wrap around the array. Loop through in two passes(upper and lower)
                        for (int i = takeIndex; i < buffer.length; i++) {
                            retArray[retArrayIndex] = buffer[i];
                            retArrayIndex++;
                        }
                        for (int i = 0; i < putIndex; i++) {
                            retArray[retArrayIndex] = buffer[i];
                            retArrayIndex++;
                        }
                    }
                }
            }
        }
        return retArray;

    }
537738
public static <T, J extends Convertable<T>> T[] convertToArray(Collection<J> collection) {
        return toArray(convert(collection));
    }
259058
public static <T> T[] toArray(Iterable<? extends T> iterable, T[] target)
    {
        if (iterable instanceof Collection)
        {
            return ((Collection<T>) iterable).toArray(target);
        }
        if (iterable instanceof RichIterable)
        {
            return ((RichIterable<T>) iterable).toArray(target);
        }
        MutableList<T> result = Lists.mutable.empty();
        Iterate.addAllTo(iterable, result);
        return result.toArray(target);
    }
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);
	}
567062
function arrayToList(array) {
  if(isArray(array)) {
    return List.fromArray(array)
  }
  else if(isFunction(array)) {
    return function(x) {
      const g = array(x)

      if(!isArray(g)) {
        throw new TypeError('arrayToList: Array returning function required')
      }

      return List.fromArray(g)
    }
  }

  throw new TypeError('arrayToList: Array or Array returning function required')
}
1328299
function convertArrayToObject(array) {
      var temp = [];
      array.forEach(function (text) {
        temp.push({
          index: text
        });
      });
      return temp;
    }
1027741
function toArray(arrayLike) {
        if (arrayLike === undefined || arrayLike === null) {
            return [];
        }
        if (Array.isArray(arrayLike)) {
            return arrayLike;
        }
        return [arrayLike];
    }
25085
function objectToArray(o, order) {
    order = order || Object.keys(o);

    return order.map(function(k) {
      return o[k];
    });
  }
174920
function toArray(item) {
	if (!(item instanceof Array)) {
		var newitem = [];
		if (item) {
			newitem.push(item);
		}
		return newitem;
	}
	else {
		return item;
	}
}
395478
public static <T> List<T> toList(T[] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
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;
    }