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

        

  • 相关阅读:
    WebApp匯入資料之對話框實現
    JSON學習
    [JSON]jQuery的parseJSON()函數使用
    DataTable.Merge()一次應用
    WebApp匯入資料之From Excel
    含有HTML碼的欄位寫入資料庫處理方法
    访问Webservice错误
    ASP.NET整合應用實例後端Services合作
    强直性脊柱炎活动指数(ASDAS)在日常诊疗种评估生物制剂治疗患者的应用-来自葡萄牙登记系统风湿病患者
    脊柱炎症水平在疾病活动度高低不等的脊柱关节炎患者中表现相似-来自一项群体研究结果
  • 原文地址:https://www.cnblogs.com/Newbie-Cai/p/5842513.html
Copyright © 2011-2022 走看看