• 插入数组但不影响原来排序


    function array_intsort($array,$num) {
    02        $array_right = $array_left = array();
    03         
    04        $length = count($array);
    05        if ($num < $array[0]) {
    06            array_unshift($array,$num);
    07            return $array;
    08        } else {
    09            for($i=0; $i < $length; $i++) {
    10                if ($i + 1 < $length) {
    11                    if ($array[$i] < $num && $num < $array[$i+1]) {
    12                        $array_right = array_slice($array,$i + 1);           
    13                        $array_left = array_slice($array,0,$i);
    14                        $array_left[] = $num;               
    15                        break;
    16                    }
    17                } else {
    18                    $array_left = $array;
    19                    $array_left[] = $num;           
    20                }
    21            }
    22            return array_merge($array_left,$array_right);
    23        }
    24    }

  • 相关阅读:
    Guava Enums
    Guava CharMatcher
    Guava CaseFormat
    HotSpot Generations
    Java Run-Time Data Areas
    Reloading Java Classes 201: How do ClassLoader leaks happen? Translation
    Guava BiMap AbstractBiMap
    Reloading Java Classes 101: Objects, Classes and ClassLoaders Translation
    Guava CompoundOrdering
    Chapter 4 -- Throwables
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2891939.html
Copyright © 2020-2023  润新知