类 Collections


  • public class Collections
    extends Object
    集合工具
    作者:
    frankcl
    • 构造器详细资料

      • Collections

        public Collections()
    • 方法详细资料

      • binarySearch

        public static <E> int binarySearch​(List<E> elements,
                                           E e,
                                           Comparator<E> comparator)
        二分查找 comparator为空:保证元素类型实现Comparable接口
        类型参数:
        E -
        参数:
        elements - 有序列表
        e - 查找元素
        comparator - 比较器
        返回:
        成功返回下标,否则返回-1
      • sortHeap

        public static <E> void sortHeap​(List<E> elements,
                                        Comparator<E> comparator)
        堆排序 comparator为空:保证元素类型实现Comparable接口
        类型参数:
        E -
        参数:
        elements - 排序列表
        comparator - 比较器
      • sortQuick

        public static <E> void sortQuick​(List<E> elements,
                                         Comparator<E> comparator)
        快速排序 comparator为空:保证元素类型实现Comparable接口
        类型参数:
        E -
        参数:
        elements - 排序列表
        comparator - 比较器
      • combination

        public static <V> List<List<V>> combination​(List<V> elements,
                                                    int m)
        从列表中选择m个元素进行组合
        类型参数:
        V -
        参数:
        elements - 元素列表
        m - 选择数量
        返回:
        组合结果
      • permutation

        public static <V> List<List<V>> permutation​(List<V> elements,
                                                    int m)
        从列表elements中选择m个元素进行排列
        类型参数:
        V -
        参数:
        elements - 元素列表
        m - 选择数量
        返回:
        排列结果