zoukankan      html  css  js  c++  java
  • 类Collections的静态方法

    类Collections的静态方法

    此类完全由在 collection 上进行操作或返回 collection 的静态方法组成。

    排序

        static <T extends Comparable<? super T>>  void  sort(List<T> list)

        static <T>   void   sort(List<T> list, Comparator<? super T> c)

    交换

        static void   swap(List<?> list,  int i, int j)

    二分搜索法

        static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key)

        static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c)

    获取最大值

        static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)

         根据元素的自然顺序,返回给定 collection 的最大元素。
         static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)
        根据指定比较器产生的顺序,返回给定 collection 的最大元素。

    获取最小值

        static <T extends Object & Comparable<? super T>> T  min(Collection<? extends T> coll)

         根据元素的自然顺序,返回给定 collection 的最大元素。
         static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
        根据指定比较器产生的顺序,返回给定 collection 的最大元素。

    反转顺序

        static <T> Comparator<T> reverseOrder() 

         返回一个比较器,它强行逆转实现了 Comparable 接口的对象 collection 的自然顺序。
         static <T> Comparator<T> reverseOrder(Comparator<T> cmp)
         返回一个比较器,它强行逆转指定比较器的顺序。

    替换

        static <T> boolean replaceAll(List<T> list, T oldVal, T newVal)

        使用另一个值替换列表中出现的所有某一指定值。

        static <T> void fill(List<? super T> list, T obj)

        使用指定元素替换指定列表中的所有元素。

    随机置换

        static void shuffle(List<?> list)

        使用默认随机源对指定列表进行置换。

        static void shuffle(List<?> list, Random rnd)
        使用指定的随机源对指定列表进行置换。

        

  • 相关阅读:
    英语影视台词---三、Cinema Paradiso
    英语影视台词---二、Inception
    智课雅思短语---二、exert positive/ negative effects on…
    MVC 编程模型及其变种
    四:redis的sets类型
    HDU 2048 号码塔(DP)
    删除句子UITableView额外的底线和切割线
    css+html菜单适应性学习的宽度
    删RAC中间ASM和LISTENER 资源的正确方法
    联合县城市,采用ajax,而使用ul模拟select下拉
  • 原文地址:https://www.cnblogs.com/Newbie-Cai/p/5842513.html
Copyright © 2011-2022 走看看