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)
        使用指定的随机源对指定列表进行置换。

        

  • 相关阅读:
    2020软件工程最后一次作业 it
    javaArrayList it
    js二进制数据转图片 it
    002addTwoNumbers it
    1.1选择select it
    js保存图片至本地 it
    npm ERR! code E404 it
    2020软件工程第三次作业 it
    2020软件工程第二次作业 it
    react打包后找不到静态文件 it
  • 原文地址:https://www.cnblogs.com/Newbie-Cai/p/5842513.html
Copyright © 2011-2022 走看看