[resolveTypeIndex 根据类型多级分类]
@DateTime 2018-10-09
@param    [type]     $arr [description]
@return   [type]          [description]
183130
private function resolveTypeIndex()
    {
        // 构建文件分类
        $archives = [];
        $files = $this->files;
        foreach ($files as $key => $file) {
            // 单页文件不做索引
            if (in_array($file['page_uuid'], $this->single_pages)) {
                continue;
            }
            // 文件类型处理
            $len = count($file['type']);
            $str = '';
            for ($i=0; $i < $len; $i++) {
                $str.= '__' . $file['type'][$i];
                $str = trim($str, '__');
                $archives[] = $str;
            }
        }
        unset($file);

        $archives = array_unique($archives);
        $keys = $archives;
        foreach ($archives as $k1 => $v1) {
            foreach ($keys as $v2) {
                if (strpos($v2, $v1) !== false && ($v1 !== $v2)) {
                    unset($archives[$k1]);
                    break;
                }
            }
        }
        unset($v1,$k1,$v2);

        $type_index = [];
        foreach ($archives as $key => $t) {
            $type = explode('__', $t);
            $length = count($type);
            $url = '/category';
            $type_index = $this->my_merge($type_index, $this->getArray(0, $length, $type, $url));
        }
        // dd($type_index);
        $this->type_index = $type_index;
    }
1348642
public function arrMapParse(&$arr){
        $temp = [];
        foreach ($arr as $k => $v){
            $temp[$this->arrMapGetName($k)] = $v;
        }
        return $temp;
    }
320901
public static function flatten(array $arr)
    {
        $flattened = [];

        array_walk_recursive($arr, function ($a) use (&$flattened) {
            $flattened[] = $a;
        });

        return $flattened;
    }
708085
public static function reindex($arr)
	{
		// reindex this level
		$arr = array_merge($arr);

		foreach ($arr as $k => &$v)
		{
			is_array($v) and $v = static::reindex($v);
		}

		return $arr;
	}
921550
public static function index_by_first_val(array $ar): array
  {
    if ( empty($ar) || !isset($ar[0]) || !\count($ar[0]) ){
      return $ar;
    }
    $cols = array_keys($ar[0]);
    $idx = array_shift($cols);
    $num_cols = \count($cols);
    $res = [];
    foreach ( $ar as $d ){
      $index = $d[$idx];
      unset($d[$idx]);
      $res[$index] = $num_cols > 1 ? $d : $d[$cols[0]];
    }
    return $res;
  }
371109
public static function get($arr, $str_path, $default=null) {
		$path = explode('.', $str_path);
		return static::array_get($arr, $path, $default);
	}
940598
private function resolveTypes($type)
    {
        $filterTypes = [];

        do {
            $filterTypes[] = $filterType = $this->filterRegistry[$type];
        } while (($type = $filterType->getParent()) !== null);

        return $filterTypes;
    }
572565
private function resolveTypes($type)
    {
        $columnTypes = [];

        do {
            $columnTypes[] = $columnType = $this->columnRegistry[$type];
        } while (($type = $columnType->getParent()) !== null);

        return $columnTypes;
    }
118510
private function resolveTypedArray($type, Context $context)
    {
        return new Array_($this->resolveSingleType(substr($type, 0, -2), $context));
    }
1201879
public static function assoc($arr, $name, $type = null)
    {
        $ret = [];
        if (empty($arr)) {
            return $ret;
        }
        if ($type == self::GETTER) {
            $method = 'get' . $name;
            foreach ($arr as $elem) {
                $ret[$elem->$method()] = $elem;
            }
        } elseif ($type == self::OBJ) {
            foreach ($arr as $elem) {
                $ret[$elem->$name] = $elem;
            }
        } else {
            foreach ($arr as $elem) {
                $ret[$elem[$name]] = $elem;
            }
        }
        return $ret;
    }
1317715
public static function Deserialize($arr){
		if(is_null($arr))
			return null;
		$res=Array();
		$i=-1;
		$len=sizeof($arr);
		while(++$i<$len)
			$res[$arr[$i]->Key]=$arr[$i]->Value;
		return $res;
	}
598544
public function sortArrayByColumn(&$arr, $col)
    {
        $newArray = [];
        $sort_col = array();
        foreach ($arr as $key => $row) {
            $sort_col[$key] = strtoupper($row[$col]);
        }
        asort($sort_col, SORT_LOCALE_STRING);

        foreach ($sort_col as $key => $val) {
            $newArray[$key] = $arr[$key];
        }

        $arr = $newArray;
    }
756094
public final int resolveClassIndex(ArrayType arrayType)
    {
        int size = 0;
        int index = 0;
        constantReadLock.lock();
        try
        {
            size = getConstantPoolSize();
            index = getClassIndex(arrayType);
        }
        finally
        {
            constantReadLock.unlock();
        }
        if (index == -1)
        {
            String name = Descriptor.getFieldDesriptor(arrayType);
            int nameIndex = resolveNameIndex(name);
            index = addConstantInfo(new Clazz(nameIndex), size);
        }
        addIndexedElement(index, arrayType);
        return index;
    }
595907
public static function mode($arr)
    {
        $vals = array_count_values($arr);
        asort($vals);
        return end(array_keys($vals));
    }
463284
public static <T extends Comparable<? super T>>  int[] sort(T[] arr) {
        int[] order = new int[arr.length];
        for (int i = 0; i < order.length; i++) {
            order[i] = i;
        }
        sort(arr, order);
        return order;
    }
599853
protected function arrToCondition($arr)
    {
        $s = $p = '';
        $params = [];
        foreach ($arr as $k => $v) {
            if (is_array($v)) { //自增或自减
                switch (key($v)) {
                    case '+':
                    case 'inc':
                        $p = "`{$k}`= `{$k}`+" . abs(intval(current($v)));
                        break;
                    case '-':
                    case 'dec':
                        $p = "`{$k}`= `{$k}`-" . abs(intval(current($v)));
                        break;
                    case 'func':
                        $func = strtoupper(key(current($v)));
                        $funcParams = current(current($v));
                        foreach ($funcParams as $key => $val) {
                            if (substr($val, 0, 1) !== '`') {
                                $funcParams[$key] = '%s';
                                $params[] = $val;
                            }
                        }
                        $p = "`{$k}`= {$func}(" . implode($funcParams, ',') . ')';
                        break;
                    case 'column':
                        $p = "`{$k}`= `" . current($v) . "`";
                        break;
                    case 'raw':
                        $p = "`{$k}`= " . addslashes(current($v));//flags = (flags | 2) ^ 3
                        break;
                    default ://计算类型
                        $conKey = key($v);
                        if (!in_array(key(current($v)), ['+', '-', '*', '/', '%', '^', '&', '|', '<<', '>>', '~'])) {
                            throw new \InvalidArgumentException(Lang::get('_PARSE_UPDATE_SQL_PARAMS_ERROR_'));
                        }
                        $p = "`{$k}`= `{$conKey}`" . key(current($v)) . abs(intval(current(current($v))));
                        break;
                }
            } else {
                $p = "`{$k}`= %s";
                $params[] = $v;
            }

            $s .= (empty($s) ? '' : ',') . $p;
        }
        $this->bindParams = array_merge($params, $this->bindParams);
        return $s;
    }
100704
public static function array_to_object($arr)
    {
        if (gettype($arr) != 'array') {
            return $arr;
        }
        foreach ($arr as $k => $v) {
            if (gettype($v) == 'array' || getType($v) == 'object') {
                $arr[$k] = self::array_to_object($v);
            }
        }
        return (object)$arr;
    }