/*
Makes all the elements of an array to uppercase
@param array The array to modify
@return An array with all elements as upper case.
762187
function arrayToUpperCase(array) {
	let newArray = array.map(function (item) {
		if (Array.isArray(item)) {
			item = item.map(function (item) {
				return item.toUpperCase();
			});
		} else {
			return item.toUpperCase();
		}
	});

	return newArray;
}
162877
private String stringArray2String(String[] array) {
        StringBuilder sb = new StringBuilder("");
        for (int i = 0 ; i<array.length ; i++) {
            sb.append(array[i]);
            if (i<array.length - 1)
                sb.append("\n");
        }
        return sb.toString();
    }
1231976
public static List<String> reverse(final String[] array) {
        
        ArgUtils.notNull(array, "array");
        if(array.length == 0) {
            return new ArrayList<String>();
        }
        
        final List<String> list = Arrays.asList(array);
        Collections.sort(list, new Comparator<String>() {
            
            @Override
            public int compare(final String str1, final String str2) {
                
                int len1 = str1.length();
                int len2 = str2.length();
                
                if(len1 != len2) {
                    // 逆順
                    return Integer.compare(len1, len2) * -1;
                } else {
                    // 逆順
                    return str1.compareTo(str2) * 1;
                }
            }
        });
        
        return list;
    }
1310563
public static Object toPrimitiveArray(Object[] array) {
        Class primitiveType;
        if (array.length > 0) {
            LOG.debug("很可能array是用new Object[length]()构造的，这个时候array.getClass().getComponentType()返回的是Object类型，这不是我们期望的" +
                    "我们希望使用元素的实际类型，这里有一个风险点，即数组类型不一致,后面可能就会抛出类型转换异常");
            primitiveType = Reflection.getPrimitiveType(array[0].getClass());
        } else {
            primitiveType = Reflection.getPrimitiveType(array.getClass().getComponentType());
        }
        Object primitiveArray = Array.newInstance(primitiveType, array.length);
        for (int i = 0; i < array.length; i++) {
            Array.set(primitiveArray, i, array[i]);
        }
        return primitiveArray;
    }
1124080
public static function arrayKeyUpper($arr)
    {
        return array_map(function($item){
            if(is_array($item)) {
                $item = self::arrayKeyUpper($item);
            }
            return $item;
        },array_change_key_case($arr,CASE_UPPER));
    }
1105309
public static <E> E at(long index, E[] array) {
        final Iterator<E> filtered = new FilteringIterator<E>(new ArrayIterator<E>(array), new AtIndex<E>(index));
        return new FirstElement<E>().apply(filtered);
    }
111085
public static byte[] removeNullBytes(byte[] array) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream(array.length);
		for (byte b : array) {
			if (b != 0x00) {
				baos.write(b);
			}
		}
		return baos.toByteArray();
	}
965480
public static <E extends Comparable<E>> E searchMax(E[] array) {
        if(array.length == 0) {
            throw new IllegalArgumentException("The array you provided does not have any elements");
        }
        E max = array[0];
        for(int i = 1; i < array.length; i++) {
            if(array[i].compareTo(max) > 0 ) {
                max = array[i];
            }
        }
        return max;
    }
779148
protected function implode( $array )
    {
        $retString = '';
        if ( empty( $array ) )
        {
            return '';
        }
        foreach ( $array as $key => $value )
        {
            if ( is_array( $value ) )
            {
                $value = $this->implode( $value );
            }
            $retString .= $key . ' ' . $value . ' ';
        }

        return $retString;
    }
208111
public static List primitiveArrayToList(Object array) {
        int size = Array.getLength(array);
        List list = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            Object item = Array.get(array, i);
            if (item != null && item.getClass().isArray() && item.getClass().getComponentType().isPrimitive()) {
                item = primitiveArrayToList(item);
            }
            list.add(item);
        }
        return list;
    }
692283
private static String[] appendToStringArray(String[] array, String element) {
        if (array != null) {
            String[] newArray = new String[array.length + 1];
            System.arraycopy(array, 0, newArray, 0, array.length);
            newArray[array.length] = element;
            return newArray;
        } else {
            return new String[]{element};
        }
    }
1196538
public static function arrayToCss($array){
        $css = '';

        // rebuild CSS
        foreach($array as $key1 => $value1){
            $css .= $key1 . '{';

            foreach($value1 as $key2 => $value2){
                // in the case that the code is embedded in a media query
                if(is_array($value2)){
                    foreach($value2 as $value3){
                        $css .= $key2 . '{';
                        foreach($value3 as $mProp){
                            $css .= $mProp . ':' . $value3 . ';';
                        }
                        $css .= '}';
                    }
                }
                // regular selectors
                else{
                    $css .= $key2 . ':' . $value2 . ';';
                }
            }
            $css .= "}\n";
        }
        return $css;
    }
980253
private function arraySnakeCase($array)
    {
        $newArray = [];

        foreach ($array as $key => $value) {
            $newArray[snake_case($key)] = $value;
        }

        return $newArray;
    }
369011
public static String[] sortStringArray(String[] array) {
        if (isEmpty(array)) {
            return new String[0];
        }
        Arrays.sort(array);
        return array;
    }
631892
public static function escapeArray( $array )
    {
        $db = eZDB::instance();
        $out = array();
        foreach( $array as $key => $value )
        {
            if ( is_array( $value ) )
            {
                $tmp = array();
                foreach( $value as $valueItem )
                {
                    $tmp[] = $db->escapeString( $valueItem );
                }
                $out[$key] = $tmp;
                unset( $tmp );
            }
            else
                $out[$key] = $db->escapeString( $value );
        }
        return $out;
    }
458474
public static <T> Set<T> arrayToSet(T [] array) {
        return new HashSet<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;
    }